Skip to content

Instantly share code, notes, and snippets.

@tanema
Created December 12, 2014 17:50
Show Gist options
  • Save tanema/2609264682a0c8606733 to your computer and use it in GitHub Desktop.
Save tanema/2609264682a0c8606733 to your computer and use it in GitHub Desktop.
Rails and haproxy in one script for our front end guy
#! /bin/bash
# used for kill signals
kill_rails () {
kill -6 ${rails_pid} > /dev/null 2>&1
}
#get password for haproxy
read -s -p "Enter Password: " proxy_pass
echo ""
#allows ctrl c to work in the while loop
trap kill_rails SIGINT SIGHUP SIGTERM
#start the processes
rails s &
rails_pid=($!)
#we wait on haproxy while rails runs in bg
echo $proxy_pass | sudo -S haproxy -f ./config/haproxy.cfg
@astjohn
Copy link

astjohn commented Dec 12, 2014

sweet!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment