Skip to content

Instantly share code, notes, and snippets.

@mrister
Last active April 6, 2019 19:06
Show Gist options
  • Save mrister/dc9e0e76bfe450a75ef0fddb4900fce6 to your computer and use it in GitHub Desktop.
Save mrister/dc9e0e76bfe450a75ef0fddb4900fce6 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