Skip to content

Instantly share code, notes, and snippets.

@rodolfobandeira
Forked from katafrakt/puma_rc.d.sh
Created April 13, 2018 01:00
Show Gist options
  • Save rodolfobandeira/3c6fbf31c45954e3482061098d3b28b0 to your computer and use it in GitHub Desktop.
Save rodolfobandeira/3c6fbf31c45954e3482061098d3b28b0 to your computer and use it in GitHub Desktop.
simple and stupid Arch Linux rc.d script for starting and stopping puma (http://puma.io) with certain rails app
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
. /etc/profile
DAEMON=prozatorium
PIDFILE=/path/to/pidfile
app_path=/path/to/rails_app
config=config/puma.rb
logfile=log/puma.log
case "$1" in
start)
stat_busy "Starting $DAEMON"
[ -z "$PID" ] && cd $app_path && bundle exec puma --pidfile $PIDFILE -C $config &>/dev/null >> $logfile &
if [ $? = 0 ]; then
add_daemon $DAEMON
stat_done
else
stat_fail
exit 1
fi
;;
stop)
PID=`cat $PIDFILE`
stat_busy "Stopping $DAEMON"
[ -n "$PID" ] && kill $PID &>/dev/null
if [ $? = 0 ]; then
rm_daemon $DAEMON
stat_done
else
stat_fail
exit 1
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment