Skip to content

Instantly share code, notes, and snippets.

@AndrewVos
Created February 11, 2014 16:48
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 AndrewVos/8938795 to your computer and use it in GitHub Desktop.
Save AndrewVos/8938795 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
go get
go build
sudo service nginx start
prodotti_servers=`pgrep -f "prodotti server"`
if [ "$(curl -fsS localhost:9091)" == 'prodotti' ]; then
echo "Prodotti already running on port 9091, using port 9092"
port=9092
else
echo "Prodotti already running on port 9092, using port 9091"
port=9091
fi
echo "Launching new prodotti server..."
PORT=$port nohup ./prodotti server >> prodotti.log 2>&1 &
conf="/etc/nginx/sites-available/default"
echo "" > $conf
echo "server {" >> $conf
echo " listen 80 default_server;" >> $conf
echo " server_name products.shopa.com;" >> $conf
echo " location / {" >> $conf
echo " proxy_pass http://127.0.0.1:$port;" >> $conf
echo " }" >> $conf
echo "}" >> $conf
nginx -s reload
echo "Killing old prodotti servers..."
echo $prodotti_servers | xargs kill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment