나는 사용하고있다os-svc-daemon
OpenStack 프로젝트를 위한 신생 서비스를 생성합니다.
내 신생 작업 구성은 다음과 같습니다
파일 : /etc/init/myservice.conf
start on runlevel [2345]
stop on runlevel [016]
env OS_SVC_ENABLE_CONTROL=1
export OS_SVC_ENABLE_CONTROL
pre-start script
mkdir -p /var/run/myservice
chown -R root:root /var/run/myservice
end script
respawn
# the default post-start of 1 second sleep delays respawning enough to
# not hit the default of 10 times in 5 seconds. Make it 2 times in 5s.
respawn limit 2 5
exec start-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice --
post-start exec sleep 1
이 서비스는 루트 사용자로 실행됩니다.
내가 실행하면 start-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice
잘 작동합니다.
하지만 다음을 사용하여 상태를 확인할 때
~# initctl start myservice
myservice stop/starting
~# initctl status myservice
myservice stop/waiting
나도 시도했다디버깅
start on runlevel [2345]
stop on runlevel [016]
env OS_SVC_ENABLE_CONTROL=1
export OS_SVC_ENABLE_CONTROL
pre-start script
mkdir -p /var/run/myservice
chown -R root:root /var/run/myservice
end script
script
echo "DEBUG: `set`" >> /tmp/myjob.log
# rest of script follows...
end script
respawn
# the default post-start of 1 second sleep delays respawning enough to
# not hit the default of 10 times in 5 seconds. Make it 2 times in 5s.
respawn limit 2 5
exec start-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice --
post-start exec sleep 1
하지만 파일을 생성하지 않습니다./tmp
답변1
내 생각엔 당신의 명령 중 하나가사전 시작 스크립트실패하고 있습니다(아마도 mkdir). "|| true"를 추가해 보세요.
pre-start script
mkdir -p /var/run/myservice || true
chown -R root:root /var/run/myservice || true
end script
당신은PIDinitctl start myservice
명령 뒤에 나타남