Created
June 8, 2012 18:34
-
-
Save ehlertij/2897482 to your computer and use it in GitHub Desktop.
Chef recipes: proxy_up, proxy_down, haproxy_add, haproxy_remove
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
###################### | |
# proxy_up.sh.erb | |
#!/bin/bash | |
echo 'Starting emproxy...' | |
sudo monit start all -g emproxy_ngin | |
echo 'Sleeping for 5s before reloading haproxy...' | |
sleep 5 | |
echo 'Reloading haproxy...' | |
/data/ngin/shared/bin/haproxy_remove | |
ssh -o StrictHostKeyChecking=no -i /home/deploy/.ssh/internal deploy@<%= @app_master %> "sudo sed -i -r 's/(<%= @private_hostname %>:81)/<%= @private_hostname %>:8080/g' /etc/haproxy.cfg" | |
/data/ngin/shared/bin/haproxy_add | |
echo 'Done' | |
###################### | |
# proxy_down.sh.erb | |
#!/bin/bash | |
echo 'Reloading haproxy...' | |
/data/ngin/shared/bin/haproxy_remove | |
ssh -o StrictHostKeyChecking=no -i /home/deploy/.ssh/internal deploy@<%= @app_master %> "sudo sed -i -r 's/(<%= @private_hostname %>:8080)/<%= @private_hostname %>:81/g' /etc/haproxy.cfg" | |
/data/ngin/shared/bin/haproxy_add | |
echo 'Sleeping for 5s before stopping emproxy...' | |
sleep 5 | |
echo 'Stopping emproxy...' | |
sudo monit stop all -g emproxy_ngin | |
echo 'Done' | |
###################### | |
# haproxy_add | |
#!/bin/sh | |
# Add this instance back into haproxy on the app_master | |
ssh -o StrictHostKeyChecking=no -i /home/deploy/.ssh/internal deploy@<%= @app_master %> "sudo sed -i -r 's/^#*\s\sserver/ server/g' /etc/haproxy.cfg; sudo /etc/init.d/haproxy reload" | |
###################### | |
# haproxy_remove | |
#!/bin/sh | |
# Remove this instance from haproxy on the app_master | |
ssh -o StrictHostKeyChecking=no -i /home/deploy/.ssh/internal deploy@<%= @app_master %> "sudo sed -i -r 's/(.*<%= @private_hostname %>)/#&/g' /etc/haproxy.cfg; sudo /etc/init.d/haproxy reload" | |
###################### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment