From 8d869187d82b4c13381c30bdd12193a4a89fd6ae Mon Sep 17 00:00:00 2001 From: filesite Date: Sun, 24 Aug 2025 22:11:14 +0800 Subject: [PATCH] spider watcher improved --- spider_watcher.sh | 20 +++++++++++++++----- start_cloud_in_container.sh | 3 ++- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/spider_watcher.sh b/spider_watcher.sh index ef43cfb..44c355e 100755 --- a/spider_watcher.sh +++ b/spider_watcher.sh @@ -1,6 +1,10 @@ #!/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 @@ -12,17 +16,23 @@ watcher() echo "Spider is down, try to restart it." echo "Checking ulixee cloud" - cloud_num=`docker ps | grep 'Up ' | grep -v grep | wc -l` + cloud_num=`docker ps | grep 'ulixee_cloud' | 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 + cloud_installed=`docker ps -a | grep 'ulixee_cloud' | grep -v grep | wc -l` + if [ $cloud_installed -e 1 ]; then + docker start ulixee_cloud + else + docker stop ulixee_cloud + docker rm ulixee_cloud + cd $script_root + ./start_cloud_in_container.sh + fi + sleep 10 fi diff --git a/start_cloud_in_container.sh b/start_cloud_in_container.sh index f2204d4..8fc364c 100755 --- a/start_cloud_in_container.sh +++ b/start_cloud_in_container.sh @@ -26,6 +26,7 @@ chmod 777 $DATADIR_MOUNT docker run -itd --init \ --name ulixee_cloud \ --ipc=host \ + --user ulixee \ --restart unless-stopped \ --sysctl net.ipv4.tcp_keepalive_intvl=10 \ --sysctl net.ipv4.tcp_keepalive_probes=3 \ @@ -37,4 +38,4 @@ docker run -itd --init \ -e DEBUG=$DEBUG \ -e DISPLAY=:99 \ ulixee/ulixee-cloud:latest \ - xvfb-run npx @ulixee/cloud start --port=${port} + xvfb-run npx @ulixee/cloud start --port=${port} \ No newline at end of file