【发布时间】:2014-07-25 09:35:41
【问题描述】:
我正在尝试设置一个新贵的工作,但由于某种原因它在开始后立即停止
我的价格是 6.5 美分
这是我的文件:
/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);
}
然后我得到了这个文件:(我在一个记录事件的论坛上找到的)
/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
在日志文件中,我得到了更多的调试信息,但基本上上面重复了几次。
我通过运行start test-daemon 得到这个输出test-daemon start/running, process 20600
我知道 test-daemon.php 实际上并没有做任何事情......目前我只需要运行实际的工作,一旦修复了我的代码中的问题
所以从上面...有什么我做错了吗?因为只有在我运行stop test-daemon 时才应该停止工作,对吗?
任何建议将不胜感激:)
谢谢, 戴夫
【问题讨论】:
标签: php daemon centos6 upstart