I need to control the (start \ stop \ restart) perl daemon from a web application (php). Daemon starts (and starts) correctly when I use my init script (/etc/init.d/foodaemon start (works fine)) but it doesnβt work (the daemon is unmounted, but the pid file is created, because if the daemon died after creating it) when I try to run the application. In my / etc / sudoers I added
apache ALL = NOPASSWD: /etc/init.d/foodaemon
In my php script,
$cmd = "/usr/bin/sudo /etc/init.d/foodaemon start"; exec($cmd,$out,$ret);
I have all the permissions. Perl script is
#!/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) {
source share