LoginSignup
3
3

More than 5 years have passed since last update.

node.jsとpm2とgitでHerokuみたくgit pushでデプロイする

Last updated at Posted at 2014-11-20

そんな大層なもんじゃ無いです。
ダウンタイムとか考えてないですし。

git pushでデプロイするには

gitのhooksの中でpost-updateを使います。
中身を、

post-update
BRANCH=$(git rev-parse --symbolic --abbrev-ref $1)
case $BRANCH in
  "master" )
    if [ "$USER" == "mainuser" ]; then
      pm2 stop all
      cd /sites/mainsite
      git --git-dir=.git checkout $BRANCH
      git --git-dir=.git pull origin $BRANCH
      npm install
      pm2 start bin/www
    fi
  ;;
esac
  1. ブランチ名とってきて
  2. ブランチ名がmasterなら
  3. 現在のユーザーを調べてmainuserなら
  4. pm2で処理をすべて終わらせ、
  5. サイトのディレクトリに移動し、
  6. 取得
  7. 再起動

何も難しい事してませんな。
あ、bashでないと動かないので、それ以外の方は適宜修正してください。

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3