我正在开发用 PHP 编写的套接字服务器。这部分工作已经完成,但现在我需要将它作为守护进程运行。
为此,我尝试使用start-stop-daemon
但它不起作用。我的服务器正在运行 Debian。
为简化起见,我的问题是为什么以下命令不运行我的守护程序或如何调试它?
start-stop-daemon --start --quiet --background --make-pidfile --pidfile /var/run/server-ticket.pid --exec /usr/local/zend/bin/php /var/www/server/consultpilot/ServerTicket.php >> /var/log/server-ticket.log 2>> /var/log/server-ticket.log </dev/null
Run Code Online (Sandbox Code Playgroud)
以下是完整脚本,基于Till Klampaeckel 的教程:
start-stop-daemon --start --quiet --background --make-pidfile --pidfile /var/run/server-ticket.pid --exec /usr/local/zend/bin/php /var/www/server/consultpilot/ServerTicket.php >> /var/log/server-ticket.log 2>> /var/log/server-ticket.log </dev/null
Run Code Online (Sandbox Code Playgroud)
有关信息,当我开始这个过程时,没有回报。但是当我完成它时,它告诉我没有相应的进程:
root:/var/run$ service server-ticket start
Starting Daemon for the Server Ticket from DiffMed: result : 0
server-ticket.
root:/var/run$ service server-ticket stop
Stopping Daemon for the Server Ticket from DiffMed: start-stop-daemon: warning: failed to kill 5772: No such process
1 pids were not killed
No process in pidfile '/var/run/server-ticket.pid' found running; none killed.
Run Code Online (Sandbox Code Playgroud)
从start-stop-daemon(8)
手册页:
-x, --exec 可执行文件 Check for processes that are instances of this executable (according to /proc/pid/exe)
这意味着它将检查 的实例/usr/local/zend/bin/php
,如果发现它们,则不会启动新进程。前提是你有这样的神奇饼干:
#! /usr/local/zend/bin/php
Run Code Online (Sandbox Code Playgroud)
在 /var/www/server/consultpilot/ServerTicket.php 脚本的第一行,并确保它可以使用 执行chmod
,然后您可以将其更改为:
DAEMON=/var/www/server/consultpilot/ServerTicket.php
Run Code Online (Sandbox Code Playgroud)
并获得您期望的结果。
归档时间: |
|
查看次数: |
5438 次 |
最近记录: |