-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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