Systemd

為什麼 sensu-client 不在 Travis 上的 docker 中啟動?

  • August 8, 2016

這個 Ansible 角色已經被創建,並且這個 .travis.yml被用作一個例子來測試這個角色。除 sensu-client 外,所有服務都可以啟動。

嘗試解決問題

為了解決這個問題,在 travis 中添加了一個調試步驟。建構完成後拋出以下錯誤:

The command "sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml | grep -q 'changed=0.*failed=0' && (echo 'Idempotence test: pass' && exit 0) || (echo 'Idempotence test: fail' && exit 1)

" exited with 1.

0.07s$ sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm sudo systemctl status sensu-client.service -l

● sensu-client.service - LSB: Sensu monitoring framework client

  Loaded: loaded (/etc/rc.d/init.d/sensu-client)

  Active: failed (Result: exit-code) since Mon 2016-08-08 00:18:20 UTC; 131ms ago

    Docs: man:systemd-sysv-generator(8)

 Process: 1534 ExecStart=/etc/rc.d/init.d/sensu-client start (code=exited, status=1/FAILURE)

Aug 08 00:18:19 c6354976113c systemd[1]: Starting LSB: Sensu monitoring framework client...

Aug 08 00:18:19 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: line 71: /etc/init.d/functions: No such file or directory

Aug 08 00:18:19 c6354976113c sensu-client[1534]: Starting sensu-client/etc/init.d/sensu-service: line 79: daemon: command not found

Aug 08 00:18:20 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: line 88: echo_failure: command not found

Aug 08 00:18:20 c6354976113c systemd[1]: sensu-client.service: control process exited, code=exited status=1

Aug 08 00:18:20 c6354976113c systemd[1]: Failed to start LSB: Sensu monitoring framework client.

Aug 08 00:18:20 c6354976113c systemd[1]: Unit sensu-client.service entered failed state.

Aug 08 00:18:20 c6354976113c systemd[1]: sensu-client.service failed.

當 ansible 角色部署在遠端系統上時,sensu-client 啟動,但它在 Travis 上失敗,儘管其他服務能夠啟動。

簡潔的

initscripts包裹不見了。這是在將駐留在/etc/init.d本地系統上的文件與駐留在 Travis 使用的 docker 容器中的文件進行比較後發現的。查詢後/etc/init.d/functions很清楚必須安裝什麼軟體包。

詳細

中似乎缺少文件/etc/init.d,即:

Aug 08 00:18:19 c6354976113c sensu-client[1534]: /etc/init.d/sensu-service: 
line 71: /etc/init.d/functions: No such file or directory

真的嗎?為了檢查是否添加了另一個調試步驟:ls /etc/init.d. 結果如下:

$ sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ls /etc/init.d

README  sensu-api  sensu-client  sensu-server  sensu-service  uchiwa

functions確實失踪了。這個文章表明initscripts需要安裝。當這個包被添加到 Dockerfile並且建構再次執行時,它成功了

引用自:https://serverfault.com/questions/795383