![如何调试导致 Upstart 崩溃的服务(在本例中为主管)](https://linux22.com/image/1000421/%E5%A6%82%E4%BD%95%E8%B0%83%E8%AF%95%E5%AF%BC%E8%87%B4%20Upstart%20%E5%B4%A9%E6%BA%83%E7%9A%84%E6%9C%8D%E5%8A%A1%EF%BC%88%E5%9C%A8%E6%9C%AC%E4%BE%8B%E4%B8%AD%E4%B8%BA%E4%B8%BB%E7%AE%A1%EF%BC%89.png)
我正在运行 Ubuntu 14.04。我配置了几个在启动时运行的服务,其中一个是监督者。我启动到运行级别 2,因此所有服务都/etc/rc2.d/
应该在启动时启动。
/etc/rc2.d/S20supervisor
/etc/init.d/supervisor
按照预期,在 处运行主管启动脚本。我看到脚本在 处执行/var/log/boot.log
。在它之后应该运行的每个脚本都没有运行。就好像主管脚本“使”Upstart“崩溃”了一样。
如果我编辑S20supervisor
为S10supervisor
,则会导致主管首先执行,而不会执行其他任何内容。此后,主管正常运行。
如果我编辑S20supervisor
为s99supervisor
,则会导致主管最后执行,然后执行其他所有内容。此后,主管正常运行。
因此,看起来服务启动没有问题,但由于某种原因,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 正在控制线程。
解决方案是让主管在启动后进入后台,但一旦我实际执行修复,我会发布更多详细信息。