Skip to content

Instantly share code, notes, and snippets.

@wkei
Last active January 26, 2018 10:25
Show Gist options
  • Save wkei/6d984c47da980fd954bc05029f626800 to your computer and use it in GitHub Desktop.
Save wkei/6d984c47da980fd954bc05029f626800 to your computer and use it in GitHub Desktop.
Basic PM2 Configuration
export SERVER_USER=xxyy
export SERVER_IP=xxx.yyy.xxx.yyy
export PROJECT_PATH=/home/user/xxyy
export PORT=4321
{
"name": "xxyy",
"version": "1.0.0",
"license": "MIT",
"scripts": {
"start": "nodemon app.js",
"setup": "source ./env && pm2 deploy ./pm2.config.js production setup",
"addenv": "source ./env && scp ./env $SERVER_USER@$SERVER_IP:$PROJECT_PATH/source/env",
"deploy": "source ./env && pm2 deploy ./pm2.config.js production"
}
}
module.exports = {
apps: [{
name: 'xxyy'
}],
deploy: {
production: {
user: process.env.SERVER_USER,
host: process.env.SERVER_IP,
path: process.env.PROJECT_PATH,
repo: '[email protected]:xx/yy.git',
ref: 'origin/master',
'post-deploy': 'source ./env && yarn && pm2 startOrRestart ./pm2.config.js --env production',
env: {
NODE_ENV: 'production',
PORT: process.env.PORT
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment