我正在使用launchd启动supervisord,而supervisord又启动一个小的python文件,这是一个连接到reddit的机器人。
每当supervisord使用此方法启动时,它会立即发送SIGKILL。当我手动启动supervisord时,此过程启动正常,并将一直工作,直到手动退出。
2019-03-23 21:06:49,519 CRIT Supervisor is running as root. Privileges were not dropped because no user is specified in the config file. If you intend to run as root, you can set user=root in the config file to avoid this message.
2019-03-23 21:06:49,519 INFO Increased RLIMIT_NOFILE limit to 1024
2019-03-23 21:06:49,537 INFO RPC interface 'supervisor' initialized
2019-03-23 21:06:49,538 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2019-03-23 21:06:49,542 INFO daemonizing the supervisord process
2019-03-23 21:06:49,584 INFO supervisord started with pid 142
2019-03-23 21:06:50,653 INFO spawned: 'modbot' with pid 143
2019-03-23 21:06:50,655 WARN received SIGTERM indicating exit request
2019-03-23 21:06:50,656 INFO waiting for modbot to die
2019-03-23 21:06:53,965 INFO waiting for modbot to die
2019-03-23 21:06:57,084 INFO waiting for modbot to die
2019-03-23 21:07:00,232 INFO waiting for modbot to die
2019-03-23 21:07:01,278 WARN killing 'modbot' (143) with SIGKILL
2019-03-23 21:07:01,349 INFO stopped: modbot (terminated by SIGKILL)
最有可能(这是猜测,因为你没有在问题中包含你的launchd配置),你没有将-n
参数传递给supervisor以防止你的launchd配置中的自我守护。
当程序的主PID退出时,launchd会考虑与孤儿相关的剩余进程,并清除它们。
为了避免这种情况,永远不要将在监督系统下运行的软件配置为自我守护,除非该监督系统明确支持以下子节点并且配置为这样做。