4
我需要从Web应用程序(php)控制(启动\停止\重新启动)perl守护进程。 守护程序从命令行使用我的初始化脚本(/etc/init.d/foodaemon start(正常工作))时正确启动(并运行),但不起作用(守护进程已关闭但创建了pid文件,如同守护进程在创建之后就死亡了),当我尝试从应用程序启动时。 在我的/ etc/sudoers文件,我加如何从PHP启动 - 停止perl守护进程
apache ALL = NOPASSWD: /etc/init.d/foodaemon
在我的PHP脚本,
$cmd = "/usr/bin/sudo /etc/init.d/foodaemon start";
exec($cmd,$out,$ret);
我拥有所有权限。 perl脚本是
#!/usr/bin/perl
use strict;
use warnings;
use Proc::Daemon;
Proc::Daemon::Init;
my $continue = 1;
$SIG{TERM} = sub { $continue = 0 };
close STDIN;
open STDERR,">>/tmp/mylog";
print "My pid: $$\n";
close STDOUT;
while ($continue) {
# ... what I need
}
干得好。你为什么不在你的答案上打上绿色的选中标记,这样就不会在未回答的问题区域显示出来。 – ddoxey