Sha256: a26050c9646b494ff493f303679b5df7acd0901b0cfe83820f06e1dc6fdfd15a
Contents?: true
Size: 1.39 KB
Versions: 5
Compression:
Stored size: 1.39 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 kill -KILL $pid 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
5 entries across 5 versions & 1 rubygems