estou usandoos-svc-daemon
para criar meu serviço inicial para o projeto openstack.
minha configuração de trabalho inicial é a seguinte
Arquivo: /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
Este serviço é executado como usuário root.
Se eu executar start-stop-daemon --start -c root --exec /opt/stack/venvs/openstack/bin/myservice
, está funcionando bem.
Mas quando verifico o status usando
~# initctl start myservice
myservice stop/starting
~# initctl status myservice
myservice stop/waiting
Eu também tenteiDepuração
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
Mas não é criar arquivo em/tmp
Responder1
meu palpite é que um dos comandos no seuscript de pré-inícioestá falhando (mkdir provavelmente). Tente anexar "|| true"
pre-start script
mkdir -p /var/run/myservice || true
chown -R root:root /var/run/myservice || true
end script
Você deveria ver umpidaparece após o initctl start myservice
comando