Ubuntu, upstart, and creating a pid for monitoring

前端 未结 2 1689
不知归路
不知归路 2020-12-22 21:22

Below is a upstart script for redis. How to I create a pid so I use monit for monitoring?

#!upstart
description \"Redis Server\"

env USER=redis

start on s         


        
2条回答
  •  星月不相逢
    2020-12-22 21:41

    Egg's 1st example with start-stop-daemon is way to go.

    If You choose 2nd, I would suggest $$ to obtain the PID.

    #!upstart
    description "Redis Server"
    
    env USER=redis
    
    start on startup
    stop on shutdown
    
    respawn
    
    script
        echo $$ > /var/run/app_name.pid
        exec sudo -u $USER sh -c "/usr/local/bin/redis-server /etc/redis/redis.conf 2>&1 >> /var/log/redis/redis.log"
    end script
    
    post-stop script
        rm -f /var/run/app_name.pid
    end script
    

提交回复
热议问题