Sha256: 221b4ff453c7d04c67383e8a12be03bd380728ab360ae3a1af70aad3490450d3
Contents?: true
Size: 1.82 KB
Versions: 1
Compression:
Stored size: 1.82 KB
Contents
#!/usr/bin/env bash # This monit wrapper script will be called by monit as root # Edit these variables to your liking RAILS_ENV={{ be_app_env }} USER={{ deployer_user.name }} APP_DIR={{ be_app_path }} PUMA_CONFIG_FILE=$APP_DIR/config/puma.production.rb PUMA_PID_FILE={{ puma_pidfile }} PUMA_SOCKET={{ puma_sockfile }} # check if puma process is running puma_is_running() { if [ -S $PUMA_SOCKET ] ; then if [ -e $PUMA_PID_FILE ] ; then if cat $PUMA_PID_FILE | xargs pgrep -P > /dev/null ; then return 0 else echo "No puma process found" fi else echo "No puma pid file found" fi else echo "No puma socket found" fi return 1 } case "$1" in start) echo "Starting puma..." rm -f $PUMA_SOCKET if [ -e $PUMA_CONFIG_FILE ] ; then echo "cd $APP_DIR && RAILS_ENV=$RAILS_ENV bundle exec puma -C $PUMA_CONFIG_FILE --daemon" /bin/su - $USER -c "cd $APP_DIR && RAILS_ENV=$RAILS_ENV bundle exec puma -C $PUMA_CONFIG_FILE --daemon" else echo "ERROR: No config file found in $PUMA_CONFIG_FILE" fi echo "done" ;; stop) echo "Stopping puma..." echo "cd $APP_DIR && RAILS_ENV=$RAILS_ENV bundle exec pumactl stop" /bin/su - $USER -c "cd $APP_DIR && RAILS_ENV=$RAILS_ENV bundle exec pumactl --config-file $PUMA_CONFIG_FILE stop" rm -f $PUMA_PID_FILE rm -f $PUMA_SOCKET echo "done" ;; restart) if puma_is_running ; then echo "Hot-restarting puma..." /bin/su - $USER -c "cd $APP_DIR && RAILS_ENV=$RAILS_ENV bundle exec pumactl restart" echo "Doublechecking the process restart..." sleep 15 if puma_is_running ; then echo "done" exit 0 else echo "Puma restart failed :/" fi fi ;; *) echo "Usage: puma {start|stop|restart}" >&2 ;; esac
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
taperole-2.0.2 | roles/puma_install/templates/puma_init.j2 |