从具有start-stop-daemon的LSB init脚本启动PHP守护程序

我正在写一个lsb init脚本(不可否认的是我从未做过的事情),它启动了一个自我守护的PHP脚本. PHP脚本就像这样开始:
#!/usr/bin/env PHP
<?PHP
/* do some stuff */

然后在init脚本中启动它:

# first line is args to start-stop-daemon,second line is args to PHP-script
start-stop-daemon --start --exec /path/to/executable/PHP-script.PHP \
  -- --daemon --pid-file=$PIDFILE --other-PHP-script-args

–daemon标志导致PHP脚本分离&作为守护进程本身运行,而不是依靠start-stop-daemon来分离它.

这是它(尝试)在init脚本中停止它的方式:

start-stop-daemon --stop --oknodo --exec /path/to/executable/PHP-script.PHP \
  --pidfile $PIDFILE

问题是,当我尝试通过init脚本停止时,它给了我:

$sudo /etc/init.d/my-lsb-init-script stop
 * Stopping My Project
No /path/to/executable/PHP-script.PHP found running; none killed.
   ...done.

快速查看ps告诉我,即使PHP脚本本身是可执行的,它也可以作为PHP< script>运行.而不是脚本名称本身,这使得start-stop-daemon看不到它. PID文件甚至正在生成,但似乎忽略它并尝试通过进程名称查找kill.

$ps ax | grep '/path/to/executable/PHP-script.PHP'
 2505 pts/1    S      0:01 PHP /path/to/executable/PHP-script.PHP --daemon --pid-file /var/run/blah/blah.pid --other-PHP-script-args
 2507 pts/1    S      0:00 PHP /path/to/executable/PHP-script.PHP --daemon --pid-file /var/run/blah/blah.pid --other-PHP-script-args
 2508 pts/1    S      0:00 PHP /path/to/executable/PHP-script.PHP --daemon --pid-file /var/run/blah/blah.pid --other-PHP-script-args
 2509 pts/1    S      0:00 PHP /path/to/executable/PHP-script.PHP --daemon --pid-file /var/run/blah/blah.pid --other-PHP-script-args
 2518 pts/1    S      0:01 PHP /path/to/executable/PHP-script.PHP --daemon --pid-file /var/run/blah/blah.pid --other-PHP-script-args
$cat /var/run/blah/blah.pid
2518

在这里完全误解了什么吗?或者有一种简单的方法可以解决这个问题吗?

正确停止:
start-stop-daemon --stop --oknodo --pidfile $PIDFILE

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...