How to monitor delayed_job with monit

后端 未结 13 811
醉酒成梦
醉酒成梦 2020-12-02 04:11

Are there any examples on the web of how to monitor delayed_job with Monit?

Everything I can find uses God, but I refuse to use God since long running processes in

13条回答
  •  一生所求
    2020-12-02 04:29

    If your monit is running as root and you want to run delayed_job as my_user then do this:

    /etc/init.d/delayed_job:

    #!/bin/sh
    #   chmod 755 /etc/init.d/delayed_job
    #   chown root:root /etc/init.d/delayed_job
    
    case "$1" in
      start|stop|restart)
        DJ_CMD=$1
        ;;
      *)
        echo "Usage: $0 {start|stop|restart}"
        exit
    esac
    
    su -c "cd /var/www/my_app/current && /usr/bin/env bin/delayed_job $DJ_CMD" - my_user
    

    /var/www/my_app/shared/monit/delayed_job.monitrc:

    check process delayed_job with pidfile /var/www/my_app/shared/tmp/pids/delayed_job.pid
    start program = "/etc/init.d/delayed_job start"
    stop  program = "/etc/init.d/delayed_job stop"
    if 5 restarts within 5 cycles then timeout
    

    /etc/monit/monitrc:

    # add at bottom
    include /var/www/my_app/shared/monit/*
    

提交回复
热议问题