|
@@ -479,9 +479,10 @@ VMESS_DIR="/jffs/vmess"
|
|
|
CONFIG="./router_local.conf"
|
|
CONFIG="./router_local.conf"
|
|
|
UPDATE_LOG="/tmp/router_local_update.log"
|
|
UPDATE_LOG="/tmp/router_local_update.log"
|
|
|
HTTP_LOG="/tmp/router_http.log"
|
|
HTTP_LOG="/tmp/router_http.log"
|
|
|
|
|
+HTTP_PROCESS_PATTERN='[r]outer_local_http.sh'
|
|
|
|
|
|
|
|
start_vmess_http() {
|
|
start_vmess_http() {
|
|
|
- if ps | grep -v grep | grep -q 'router_local_http.sh'; then
|
|
|
|
|
|
|
+ if ps | grep -q "$HTTP_PROCESS_PATTERN"; then
|
|
|
return 0
|
|
return 0
|
|
|
fi
|
|
fi
|
|
|
|
|
|
|
@@ -499,10 +500,12 @@ sleep 10
|
|
|
start_vmess_http
|
|
start_vmess_http
|
|
|
|
|
|
|
|
cru d vmess_watchdog
|
|
cru d vmess_watchdog
|
|
|
-cru a vmess_watchdog "*/5 * * * * if ! ps | grep -v grep | grep -q 'router_local_http.sh'; then cd $VMESS_DIR && nohup sh scripts/router_local_http.sh $CONFIG >> $HTTP_LOG 2>&1 & fi"
|
|
|
|
|
|
|
+cru a vmess_watchdog "*/5 * * * * if ! ps | grep -q '$HTTP_PROCESS_PATTERN'; then cd $VMESS_DIR && nohup sh scripts/router_local_http.sh $CONFIG >> $HTTP_LOG 2>&1 & fi"
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
-`router_local_http.sh` 会保留 wrapper 进程并等待子进程里的完整 BusyBox `httpd`,所以 watchdog 用 `router_local_http.sh` 作为进程关键字可以正常判断服务是否仍在运行。示例里先 `cru d` 再 `cru a`,避免 `services-start` 被重复触发后留下旧的定时任务定义;启动 HTTP 前也会先检查进程,避免重复监听同一个端口。
|
|
|
|
|
|
|
+这里用 `[r]outer_local_http.sh` 作为 `grep` 关键字,是为了避免 watchdog 的 shell 命令在 `ps` 里匹配到自己。`router_local_http.sh` 会保留 wrapper 进程并等待子进程里的完整 BusyBox `httpd`,所以 watchdog 用这个关键字可以正常判断服务是否仍在运行。示例里先 `cru d` 再 `cru a`,避免 `services-start` 被重复触发后留下旧的定时任务定义;启动 HTTP 前也会先检查进程,避免重复监听同一个端口。
|
|
|
|
|
+
|
|
|
|
|
+如果你的固件没有 KoolShare,删除 `/koolshare/bin/ks-services-start.sh` 那一行即可;如果 Web UI 里有“启用 JFFS 自定义脚本”的选项,需要先开启,否则 `/jffs/scripts/services-start` 不会在开机时执行。
|
|
|
|
|
|
|
|
### 6.7 定时执行
|
|
### 6.7 定时执行
|
|
|
|
|
|