Skip to content

Instantly share code, notes, and snippets.

@archydragon
Created February 7, 2014 11:14
Show Gist options
  • Save archydragon/8860898 to your computer and use it in GitHub Desktop.
Save archydragon/8860898 to your computer and use it in GitHub Desktop.
init.d script template to run Thin application under user using RVM
#! /bin/sh
### BEGIN INIT INFO
# Provides: thin-app
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs
# Short-Description: Application description
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
USER="user"
DAEMON_PATH="/home/$USER/thin-app"
DAEMON=thin
DAEMONOPTS="-C thin.conf.yml"
NAME=thin-app
DESC="Application description"
PIDFILE=/tmp/$NAME.0.pid
SCRIPTNAME=/etc/init.d/$NAME
su -c "source /home/$USER/.rvm/scripts/rvm; cd $DAEMON_PATH; $DAEMON $DAEMONOPTS $1" $USER
environment: production
address: 127.0.0.1
port: 3000
socket: /tmp/thin-app.sock
servers: 3
pid: /tmp/thin-app.pid
rackup: config.ru
log: thin.log
max_conns: 512
timeout: 60
max_persistent_conns: 128
daemonize: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment