Hero scripts of machete.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
1.2 KiB

#!/bin/sh
## spider watcher, work with start_cloud_in_container.sh
## 如果遇到chrome因为开启了sandbox而启动报错,提示需要修改chrome/xx.xx.xx.xx版本所有者为root且权限改为4755
## 则手动修改/app/ulixee/node_modules/@ulixee/hero-core/.env.defaults
## 把ULX_NO_CHROME_SANDBOX=# don't force the chrome sandbox设置为ULX_NO_CHROME_SANDBOX=yes,关闭sandbox
script_root=$(dirname $0)
cd $script_root
watcher()
{
spider_num=`ps -ef | grep 'node spider.mjs' | grep -v grep | wc -l`
if [ $spider_num -lt 1 ]; then
echo "Spider is down, try to restart it."
echo "Checking ulixee cloud"
cloud_num=`docker ps | grep 'ulixee_cloud' | grep 'Up ' | grep -v grep | wc -l`
if [ $cloud_num -ge 1 ]; then
echo "ulixee cloud is alive, start spider"
cd $script_root
npm start -- config_custom.json
else
echo "ulixee cloud is down, try to restart it"
docker stop ulixee_cloud
docker rm ulixee_cloud
cd $script_root
./start_cloud_in_container.sh
sleep 10
fi
else
echo "Spider is alive"
sleep 10
fi
}
while true; do
watcher
done