Reputation: 7525
I am trying to set up an upstart job but for some reason it stops immediately after starting
I'm on Cents 6.5 btw
here are my files:
/ect/init/test-daemon.conf
start on startup
stop on shutdown
respawn
script
sudo -u root php -f /usr/share/test_daemon.php
end script
/usr/share/test-daemon.php
<?php
// The worker will execute every X seconds:
$seconds = 2;
// We work out the micro seconds ready to be used by the 'usleep' function.
$micro = $seconds * 1000000;
while(true){
// Now before we 'cycle' again, we'll sleep for a bit...
usleep($micro);
}
I have then got this file: (which I found on a forum that logs events)
/tmp/log.file
debug/ (/dev/fd/10):19735:Fri Jul 25 11:52:40 AST 2014:Job
test-daemon/ starting. Environment was: TERM=linux
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
PWD=/ JOB=test-daemon
SHLVL=1
UPSTART_INSTANCE=
UPSTART_EVENTS=starting
UPSTART_JOB=debug
INSTANCE=
_=/usr/bin/env
debug/ (/dev/fd/9):19775:Fri Jul 25 11:52:41 AST 2014:Job test-daemon/ stopping. Environment was:
TERM=linux
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
PWD=/
JOB=test-daemon
RESULT=ok
SHLVL=1
UPSTART_INSTANCE=
UPSTART_EVENTS=stopping
UPSTART_JOB=debug
INSTANCE=
_=/usr/bin/env
debug/ (/dev/fd/9):19779:Fri Jul 25 11:52:41 AST 2014:Job test-daemon/ stopping. Environment was:
TERM=linux
PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin
PWD=/
JOB=test-daemon
RESULT=failed
SHLVL=1
PROCESS=respawn
UPSTART_INSTANCE=
UPSTART_EVENTS=stopping
UPSTART_JOB=debug
INSTANCE=
_=/usr/bin/env
in the log file, I get more debug information but its basically the above repeated a few times.
I get this from running start test-daemon
which outputs test-daemon start/running, process 20600
I know the test-daemon.php doesn't actually do anything...at the moment I just need to get the actual job running, once thats fixed ill drop in my code
So from the above...is there anything I am doing wrong? as the job should only stop if I run stop test-daemon
right?
Any suggestions would be much appreciated :)
Thanks, Dave
Upvotes: 0
Views: 684
Reputation: 770
I'd rather post a comment but with the low reputation limit I can not. I am not familiar with this distro flavor but did you try to use nohup ? Like this:
nohup php -f /usr/share/test_daemon.php &
It could be possible that detaching your command from the service process kills it.
Upvotes: 1