被系统杀死后,自动重新启动monit

问题描述 投票:0回答:1

我正在使用监控程序来监视我的WEB服务。一切正常,直到监视进程被系统终止。监视日志文件的一部分显示了该问题

monit log file

要让monit在启动时自动启动并在失败时重新启动,我为monit添加了upstart配置(我正在运行Ubuntu 14.04),如下所示:

    # This is an upstart script to keep monit running.
    # To install disable the old way of doing things:
    #
    #   /etc/init.d/monit stop && update-rc.d -f monit remove
    #
    # then put this script here:
    #
    #   /etc/init/monit.conf
    #
    # and reload upstart configuration:
    #
    #   initctl reload-configuration
    #
    # You can manually start and stop monit like this:
    # 
    # start monit
    # stop monit
    #

    description "Monit service manager"

    limit core unlimited unlimited

    start on runlevel [2345]
    stop on starting rc RUNLEVEL=[016]

    expect daemon
    respawn

    exec /usr/bin/monit -c /etc/monitrc

    pre-stop exec /usr/bin/monit -c /etc/monitrc quit

当我重新启动时,系统监视器未运行。

    sudo monit status
    $ monit: Status not available -- the monit daemon is not running

我如何配置新贵以保持监视程序的运行和监视?

monitoring upstart monit
1个回答
0
投票

我在启动monit命令中有错误的配置文件路径。正确的命令是

    exec /usr/bin/monit -c /etc/monit/monitrc

    pre-stop exec /usr/bin/monit -c /etc/monit/monitrc quit

它将守护程序作为守护程序启动,并在我杀死它时重新启动:

    ps aux | grep monit
    root      2173  0.0  0.1 104348  1332 ?        Sl   04:13   0:00 /usr/bin/monit -c /etc/monit/monitrc

    sudo kill -9 2173

    ps aux | grep monit
    root      2184  0.0  0.1 104348  1380 ?        Sl   04:13   0:00 /usr/bin/monit -c /etc/monit/monitrc
© www.soinside.com 2019 - 2024. All rights reserved.