pipe理守护进程:没有可用的前台模式

我试图用supervisord来pipe理一个进程,但是这个进程没有在前台运行的选项:它总是守护进程。 (这是Zabbix服务器)。

有没有办法与主pipepipe理守护进程? 任何工具,将使其运行在前台? 或者,也许,不知何故使用pidfile?

为了解决这个问题,我们需要一些运行在前台的程序,只要守护进程退出,这些程序就会退出,同时也会向守护进程发送信号。

考虑使用下面的脚本bash脚本:

#! /usr/bin/env bash set -eu pidfile="/var/run/your-daemon.pid" command=/usr/sbin/your-daemon # Proxy signals function kill_app(){ kill $(cat $pidfile) exit 0 # exit okay } trap "kill_app" SIGINT SIGTERM # Launch daemon $command sleep 2 # Loop while the pidfile and the process exist while [ -f $pidfile ] && kill -0 $(cat $pidfile) ; do sleep 0.5 done exit 1000 # exit unexpected 

以防万一有人像我刚才那样使用search引擎来回答这个问题。

Zabbix自v3.0.0beta1提供“-f”选项在前台运行( https://support.zabbix.com/browse/ZBXNEXT-611

正如你在下面看到的,我们使用二进制的绝对path(我们从源代码编译它)开始进程,使用“-c”开关和configuration文件的绝对path提供我们的configuration文件。 然后提到的“-f”开关在前台运行进程。

我们使用的supervisordconfiguration文件如下所示:

 [program:zabbix-server] command=/opt/application/zabbix-server/3.2.7/zabbix_server -c /opt/application/zabbix-server/3.2.7/zabbix-server.conf -f startsecs=5 startretries=3 autostart=true autorestart=true user=zabbix stdout_logfile=/data/application/zabbix-server/3.2.7/log/zabbix-server.log stderr_logfile=/data/application/zabbix-server/3.2.7/log/zabbix-server-stderr.log 

请注意,我们在zabbix-server.conf中configuration

 LogType=console 

祝一切顺利