upstart 無法運行服務且無法調試

upstart 無法運行服務且無法調試

我在用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

該服務以 root 使用者身分執行。

如果我運行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

你應該看到一個PID出現在initctl start myservice命令之後

相關內容