Skip to content

Instantly share code, notes, and snippets.

@rch850
Created December 2, 2013 07:04
Show Gist options
  • Save rch850/7746093 to your computer and use it in GitHub Desktop.
Save rch850/7746093 to your computer and use it in GitHub Desktop.
git push で node アプリ走らせる時のとりあえずスクリプト。なんかいいのあったら教えて
#!/bin/sh -eu
git update-server-info
APP_HOME=/home/rch850/hogeapp
APP_BRANCH=develop
PIDFILE=$APP_HOME/node.pid
export GIT_DIR=$APP_HOME/.git
(cd $APP_HOME && git --git-dir=.git pull && git checkout $APP_BRANCH)
if [ -f $PIDFILE ]; then
PID=$(cat $PIDFILE)
rm $PIDFILE && kill $PID
fi
cd $APP_HOME && npm install
grunt stylus
nohup node app.js >& $APP_HOME.log &
echo $! > $PIDFILE
## 起動コマンドを npm start にすると、kill が node を止めてくれない
## grunt でもうまくいかない
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment