From cc661b37f394ecc2e87006251cb74451a9371a85 Mon Sep 17 00:00:00 2001 From: filesite Date: Thu, 14 Nov 2024 16:46:42 +0800 Subject: [PATCH] call main bot when docker container start --- docker-entrypoint.sh | 21 ++++++++++++------- .../beauty/controller/CommandController.php | 10 +++++++-- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0fc9408..287aa0b 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -13,11 +13,6 @@ if [ -d "/var/www/machete/themes/${theme}/" ]; then fi fi -## 启动samba -if [ -e /usr/sbin/smbd ]; then - echo "Start smbd." - /usr/sbin/smbd -D -fi ## 启动nginx和php-fpm if [ -e /usr/sbin/nginx ]; then @@ -25,5 +20,17 @@ if [ -e /usr/sbin/nginx ]; then /usr/sbin/nginx fi -echo "Start php-fpm." -php-fpm -F + +## 启动bot主程序 +if [ -e /usr/local/bin/php ]; then + echo "Start main bot." + cd /var/www/machete/ + /usr/local/bin/php bin/command.php mainBot & +fi + + +## 启动php-fpm +if [ -e /usr/local/sbin/php-fpm ]; then + echo "Start php-fpm." + php-fpm -F +fi \ No newline at end of file diff --git a/themes/beauty/controller/CommandController.php b/themes/beauty/controller/CommandController.php index 9cfa65b..78ee062 100644 --- a/themes/beauty/controller/CommandController.php +++ b/themes/beauty/controller/CommandController.php @@ -96,10 +96,16 @@ eof; //服务器端机器人程序,负责图片、视频文件拍摄时间等信息扫描,并缓存结果供前端使用 public function actionMainBot() { $thisTime = date('Y-m-d H:i:s'); - echo "Main bot started @{$thisTime}\n"; + echo "[MainBot] Main bot started @{$thisTime}\n"; - exit; + while (true) { + $time = date('Y-m-d H:i:s'); + echo "[MainBot] {$time}\n"; + + sleep(3); + } + } }