Example: Padrinorb application with nginx and thin server:
Thin
# config/thin.yml port: 3000 user: padrino group: padrino pid: tmp/pids/thin.pid timeout: 30 wait: 30 log: log/thin.log max_conns: 1024 require: [] environment: production max_persistent_conns: 512 servers: 4 threaded: true no-epoll: true daemonize: true socket: tmp/sockets/thin.sock chdir: /home/padrino/my-padrino-app tag: my-padrino-app
Nginx
Script to start, stop, restart, state
#!/usr/bin/env bash # bin/my-padrino-app-service.sh APPDIR="/home/padrino/my-padrino-app" CURDIR=$(pwd) if [[ $# -lt 1 ]] then echo echo "Usage:" echo " $0 <start|stop|restart|status>" echo exit 1 fi case $1 in "status") cat $APPDIR/tmp/pids/thin.* &> /dev/null if [[ $? -ne 0 ]] then echo "Service stopped" else for i in $(ls -C1 $APPDIR/tmp/pids/thin.*) do echo "Running: $(cat $i)" done fi ;; "start") echo "Making thin dirs..." mkdir -p $APPDIR/tmp/thin mkdir -p $APPDIR/tmp/pids mkdir -p $APPDIR/tmp/sockets echo "Starting thin..." cd $APPDIR # Production thin start -e production -C $APPDIR/config/thin.yml cd $CURDIR sleep 2 $0 status ;; "stop") cat $APPDIR/tmp/pids/thin.* &> /dev/null if [[ $? -eq 0 ]] then for i in $(ls -C1 $APPDIR/tmp/pids/thin.*) do PID=$(cat $i) echo -n "Stopping thin ${PID}..." kill $PID if [[ $? -eq 0 ]] then echo "OK" else echo "FAIL" fi done fi $0 status ;; "restart") $0 stop $0 start $0 status ;; esac
source share