Skip to content

Instantly share code, notes, and snippets.

@jbutko
Forked from mrister/pms-development.sh
Created October 22, 2016 14:33
Show Gist options
  • Save jbutko/17f9b4f777ea8522f7dce250587c8e2d to your computer and use it in GitHub Desktop.
Save jbutko/17f9b4f777ea8522f7dce250587c8e2d to your computer and use it in GitHub Desktop.
pm2 example
#!/usr/bin/env bash
#install pm2
npm i pm2
#run with process.json configuration file for development environment
pm2 start process.json --env development
# delete it all
# pm2 delete process.json
{ // very good docs at http://pm2.keymetrics.io/docs/usage/application-declaration/#attributes-available
"apps": [
{
"name": "my application",
"instances": 0, // 0 means create instances to number of CPU cores on host
"script": "app.js",
"watch": true,
"ignore_watch": [
"/[\s\S].spec.js$/", // don't restart on test file change
"node_modules",
"docs"
],
"exec_mode": "cluster", // or fork
"interpreter_args": "--harmony",
"error_file": "/var/tmp/my_application/error.log", // it will be created if nonexistent
"min_uptime": 500,
"max_restarts": 10,
"restart_delay": 1000,
"env_development": {
"NODE_ENV": "development",
"API_KEY": "albnxmzndf8"
},
"env_production": {
"NODE_ENV": "production",
"API_KEY": "praXnafinDef!1"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment