Skip to content

Commit

Permalink
Use pm2 to start the app in production mode
Browse files Browse the repository at this point in the history
  • Loading branch information
hagopj13 committed Oct 27, 2019
1 parent 9cfcd02 commit c835a97
Show file tree
Hide file tree
Showing 5 changed files with 882 additions and 42 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ It comes with many built-in features, such as authentication using JWT, request
- [Express](http://expressjs.com)
- [MongoDB](https://www.mongodb.com) object data modeling using [Mongoose](https://mongoosejs.com)
- Dependency management with [Yarn](https://yarnpkg.com)
- Advanced production process management using [PM2](https://pm2.keymetrics.io)
- Logging using [winston](https://github.com/winstonjs/winston)
- Environment variables using [dotenv](https://github.com/motdotla/dotenv) and [cross-env](https://github.com/kentcdodds/cross-env#readme)
- Git hooks with [husky](https://github.com/typicode/husky) and [lint-staged](https://github.com/okonet/lint-staged)
Expand Down
15 changes: 15 additions & 0 deletions ecosystem.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"apps": [
{
"name": "app",
"script": "src/index.js",
"instances": 1,
"autorestart": true,
"watch": false,
"time": true,
"env": {
"NODE_ENV": "production"
}
}
]
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"node": ">=12.0.0"
},
"scripts": {
"start": "cross-env NODE_ENV=production node src/index.js",
"start": "pm2 start ecosystem.config.json --no-daemon",
"dev": "cross-env NODE_ENV=development nodemon src/index.js",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
Expand All @@ -21,6 +21,7 @@
"dotenv": "^8.2.0",
"express": "^4.17.1",
"mongoose": "^5.7.7",
"pm2": "^4.1.2",
"winston": "^3.2.1"
},
"devDependencies": {
Expand Down
1 change: 0 additions & 1 deletion src/config/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const logger = winston.createLogger({
level: config.env === 'development' ? 'debug' : 'info',
transports: [
new winston.transports.Console({
level: 'debug',
stderrLevels: ['error'],
format: winston.format.combine(
config.env === 'development' ? winston.format.colorize() : winston.format.uncolorize(),
Expand Down
Loading

0 comments on commit c835a97

Please sign in to comment.