如何調試「崩潰」Upstart(在本例中為主管)的服務

如何調試「崩潰」Upstart(在本例中為主管)的服務

我運行的是 Ubuntu 14.04。我有幾個服務配置為在啟動時運行,其中之一是主管。我啟動到運行等級 2,因此所有服務/etc/rc2.d/都應在啟動時啟動。

/etc/rc2.d/S20supervisor/etc/init.d/supervisor如預期的那樣,在 處執行主管啟動腳本。我看到腳本在 中執行/var/log/boot.log。每個應該在它之後運行的腳本都沒有運行。就好像主管腳本「崩潰」了Upstart。

如果我編輯S20supervisorS10supervisor,這會導致主管首先執行,並且不會執行其他任何操作。此後supervisor就正常運作了。

如果我編輯S20supervisors99supervisor,這會導致主管最後執行,然後執行其他所有內容。此後supervisor就正常運作了。

所以看起來服務啟動沒有問題,但由於某種原因 Upstart 鎖定並且不會在主管腳本之後執行任何腳本。為什麼?

請注意,我可以手動啟動主管,而不會出現問題sudo service supervisor start,儘管有以下輸出:

$ sudo service supervisor start Starting supervisor: 2017-05-20 00:14:04,435 CRIT Supervisor running as root (no user in config file) 2017-05-20 00:14:04,435 WARN Included extra file "/etc/supervisor/conf.d/graphite.conf" during parsing 2017-05-20 00:14:04,450 INFO RPC interface 'supervisor' initialized 2017-05-20 00:14:04,450 CRIT Server 'unix_http_server' running without any HTTP authentication checking 2017-05-20 00:14:04,450 INFO supervisord started with pid 4462 2017-05-20 00:14:05,455 INFO spawned: 'statsd' with pid 4465 2017-05-20 00:14:05,458 INFO spawned: 'carbon-cache' with pid 4466 2017-05-20 00:14:05,464 INFO spawned: 'graphite-webapp' with pid 4467 2017-05-20 00:14:06,635 INFO success: statsd entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2017-05-20 00:14:06,635 INFO success: carbon-cache entered RUNNING state, process has stayed up for > than 1 seconds (startsecs) 2017-05-20 00:14:06,635 INFO success: graphite-webapp entered RUNNING state, process has stayed up for > than 1 seconds (startsecs)

答案1

Supervisor 在前台而不是後台運行,因此 Upstart 腳本不會崩潰:它掛起是因為 Supervisor 保持對線程的控制。

解決方案是讓主管在啟動後進入後台,但一旦我實際執行修復,我將發布更多詳細資訊。

相關內容