Skip to content

Instantly share code, notes, and snippets.

@someara
Created April 19, 2011 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save someara/929047 to your computer and use it in GitHub Desktop.
Save someara/929047 to your computer and use it in GitHub Desktop.
thins
payment-1:~# cat /usr/bin/payment
#!/bin/bash
set -e
trap "kill 0" SIGINT SIGTERM EXIT
if [ -f /etc/sysconfig/payment ]; then
. /etc/sysconfig/payment
fi
# process args
if [ $1 ]; then ENVIRONMENT=$1 ; fi
if [ ! $ENVIRONMENT ]; then ENVIRONMENT="production" ; fi
if [ $RVM ]; then
export GEM_PATH=/usr/local/rvm/gems/$RVM
export GEM_HOME=/usr/local/rvm/gems/$RVM/
export PATH=/usr/local/rvm/rubies/$RVM/bin:$PATH
export PATH=/usr/local/rvm/gems/$RVM/bin:$PATH
fi
echo "HELLO this is pid $$ in process group `ps --noheaders -o %r $$`"
cd /var/app/payment/current/
bundle exec thin -C /var/app/payment/current/config/thin.yml start &
BUNDLERPID=$!
echo "BUNDLERPID=$BUNDLERPID"
wait
payment-1:~# payment
HELLO this is pid 19697 in process group 19697
BUNDLERPID=19699
Starting server on 0.0.0.0:5000 ...
>> Deleting stale PID file /var/app/payment/current/tmp/pids/payment.5000.pid
Starting server on 0.0.0.0:5001 ...
>> Deleting stale PID file /var/app/payment/current/tmp/pids/payment.5001.pid
Starting server on 0.0.0.0:5002 ...
>> Deleting stale PID file /var/app/payment/current/tmp/pids/payment.5002.pid
payment-1:~# ps -eo "%U %p %P %r %a" | egrep '(thin)'
root 19709 1 19706 thin server (0.0.0.0:5000)
root 19719 1 19716 thin server (0.0.0.0:5001)
root 19729 1 19726 thin server (0.0.0.0:5002)
root 19733 19365 19732 egrep (thin)
payment-1:~#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment