Skip to content

Instantly share code, notes, and snippets.

@likejazz
Created May 25, 2018 16:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save likejazz/07a779ebc49f54b36ac8a940fdd90276 to your computer and use it in GitHub Desktop.
Save likejazz/07a779ebc49f54b36ac8a940fdd90276 to your computer and use it in GitHub Desktop.
#!/bin/sh
# This is a simple bash script that will poll github for changes to your repo,
# if found pull them down, and then rebuild and restart a API server.
while true
do
# move into your git repo where your API server src is
cd /home/deploy/workspace/go/src/github.daumkakao.com/iris/api
git fetch;
LOCAL=$(git rev-parse HEAD);
REMOTE=$(git rev-parse @{u});
# if our local revision id doesn't match the remote, we will need to pull the changes
if [ $LOCAL != $REMOTE ]; then
git pull origin master
make
killall api-v0.6
# How to make output of any shell command unbuffered?
# http://stackoverflow.com/a/25548995/3513266
stdbuf -i0 -o0 -e0 nohup ./api-v0.6 >api.log 2>api.err &
fi
echo -n "."
sleep 10 # every 10 seconds
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment