如何调试导致 Upstart 崩溃的服务(在本例中为主管)

如何调试导致 Upstart 崩溃的服务(在本例中为主管)

我正在运行 Ubuntu 14.04。我配置了几个在启动时运行的服务,其中一个是监督者。我启动到运行级别 2,因此所有服务都/etc/rc2.d/应该在启动时启动。

/etc/rc2.d/S20supervisor/etc/init.d/supervisor按照预期,在 处运行主管启动脚本。我看到脚本在 处执行/var/log/boot.log。在它之后应该运行的每个脚本都没有运行。就好像主管脚本“使”Upstart“崩溃”了一样。

如果我编辑S20supervisorS10supervisor,则会导致主管首先执行,而不会执行其他任何内容。此后,主管正常运行。

如果我编辑S20supervisors99supervisor,则会导致主管最后执行,然后执行其他所有内容。此后,主管正常运行。

因此,看起来服务启动没有问题,但由于某种原因,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 正在控制线程。

解决方案是让主管在启动后进入后台,但一旦我实际执行修复,我会发布更多详细信息。

相关内容