Sha256: 1419cf7eb34836c9c9076cf06924b0b66ca11bb2053c5f591581d983a6aa30cd
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
#!/bin/sh HOME=/home/<%= user %> PID_FILE=${PID_FILE:-<%= pid %>/<%= name %>.pid} LOG_FILE=${LOG_FILE:-<%= log %>/<%= name %>.log} STATUS_RUNNING=0 STATUS_DEAD_WITH_PID=1 STATUS_UNKNOWN=4 function checkpid() { [ -z $1 ] && return 1 [ -d /proc/$1 ] && return 0 return 1 } function start() { echo -n "Starting process $0 ..." if [ -s $PID_FILE ] then read pid < $PID_FILE if checkpid $pid 2>&1; then echo "[FAIL] process with PID ${pid} is running." exit $STATUS_UNKNOWN fi fi cd <%= engine.root %>; <%= process.command %> >> $LOG_FILE 2>&1 & if [ $? -eq 0 ]; then echo $! > $PID_FILE echo "[OK]" else echo "[FAIL]" exit $STATUS_UNKNOWN fi } function stop() { echo -n "Terminating process $0 ..." if [ -s $PID_FILE ] then read pid < $PID_FILE if checkpid $pid 2>&1; then kill -TERM $pid sleep 1 if checkpid $pid 2>&1; then echo "[FAILED TO STOP. TERMINATING]" kill -KILL $pid fi rm -f $PID_FILE else echo "[FAIL] process with PID ${pid} does not exist" exit $STATUS_DEAD_WITH_PID fi else echo "[FAIL] pid file $PID_FILE is not found" exit $STATUS_UNKOWN fi } case "$1" in start) start ;; stop) stop ;; *) echo "Usage: $0 {start|stop}" exit 0 esac exit $STATUS_RUNNING
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foreman-capistrano-0.52.5 | data/export/monit/wrapper.sh.erb |