From f74a7b048321dd2a15df32c48068520720e71cdf Mon Sep 17 00:00:00 2001 From: InGrowth Date: Thu, 20 Oct 2016 13:31:33 +0900 Subject: [PATCH 1/4] pm2 apply for production --- package.json | 24 ++++-------------------- pm2.json | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 pm2.json diff --git a/package.json b/package.json index f3fb6791c..d364b8df2 100644 --- a/package.json +++ b/package.json @@ -24,9 +24,9 @@ ], "main": "bin/server.js", "scripts": { - "start": "concurrent --kill-others \"npm run start-prod\" \"npm run start-prod-api\"", - "start-prod": "better-npm-run start-prod", - "start-prod-api": "better-npm-run start-prod-api", + "start": "pm2 start ./pm2.json", + "restart": "pm2 restart ./pm2.json", + "stop": "pm2 stop ./pm2.json", "build": "better-npm-run build", "postinstall": "npm run build", "lint": "eslint -c .eslintrc src api", @@ -39,23 +39,6 @@ "test-node-watch": "./node_modules/mocha/bin/mocha $(find api -name '*-test.js') --compilers js:babel-core/register --watch" }, "betterScripts": { - "start-prod": { - "command": "node ./bin/server.js", - "env": { - "NODE_PATH": "./src", - "NODE_ENV": "production", - "PORT": 8080, - "APIPORT": 3030 - } - }, - "start-prod-api": { - "command": "node ./bin/api.js", - "env": { - "NODE_PATH": "./api", - "NODE_ENV": "production", - "APIPORT": 3030 - } - }, "start-dev": { "command": "node ./bin/server.js", "env": { @@ -116,6 +99,7 @@ "map-props": "^1.0.0", "multireducer": "^2.0.0", "piping": "^0.3.0", + "pm2": "2.0.18", "pretty-error": "^1.2.0", "react": "^0.14.2", "react-bootstrap": "^0.28.1", diff --git a/pm2.json b/pm2.json new file mode 100644 index 000000000..3d87c844f --- /dev/null +++ b/pm2.json @@ -0,0 +1,27 @@ +{ + "apps" : [ + { + "name": "react-redux-universal-hot-example", + "script": "./bin/server.js", + "instances" : 0, + "exec_mode" : "cluster_mode", + "env": { + "NODE_PATH": "./src", + "NODE_ENV": "production", + "PORT": 8080, + "APIPORT": 3030 + } + }, + { + "name": "react-redux-universal-hot-example_api", + "script": "./bin/api.js", + "instances" : 0, + "exec_mode" : "cluster_mode", + "env": { + "NODE_PATH": "./api", + "NODE_ENV": "production", + "APIPORT": 3030 + } + } + ] +} From 056f4974ed21fc484f5c7af289601a236a09a49e Mon Sep 17 00:00:00 2001 From: InGrowth Date: Thu, 20 Oct 2016 13:38:52 +0900 Subject: [PATCH 2/4] readme add pm2 --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index aa5c60b4b..fd22b03d1 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,13 @@ npm run build npm run start ``` +## Management Production Server + +```bash +npm run restart +npm run stop +``` + ## Demo A demonstration of this app can be seen [running on heroku](https://react-redux.herokuapp.com), which is a deployment of the [heroku branch](https://github.com/erikras/react-redux-universal-hot-example/tree/heroku). From 71e7c670f0cbc13d121ed406ea1d927fa45979cd Mon Sep 17 00:00:00 2001 From: InGrowth Date: Fri, 21 Oct 2016 01:54:52 +0900 Subject: [PATCH 3/4] exec_mode fix --- pm2.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pm2.json b/pm2.json index 3d87c844f..be0d55782 100644 --- a/pm2.json +++ b/pm2.json @@ -3,8 +3,7 @@ { "name": "react-redux-universal-hot-example", "script": "./bin/server.js", - "instances" : 0, - "exec_mode" : "cluster_mode", + "exec_mode" : "fork", "env": { "NODE_PATH": "./src", "NODE_ENV": "production", @@ -15,8 +14,7 @@ { "name": "react-redux-universal-hot-example_api", "script": "./bin/api.js", - "instances" : 0, - "exec_mode" : "cluster_mode", + "exec_mode" : "fork", "env": { "NODE_PATH": "./api", "NODE_ENV": "production", From eeaeee2614a1288516a28e3c0a1fec68ef7f9f66 Mon Sep 17 00:00:00 2001 From: InGrowth Date: Fri, 21 Oct 2016 15:44:07 +0900 Subject: [PATCH 4/4] use ^ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d364b8df2..62d8f971e 100644 --- a/package.json +++ b/package.json @@ -99,7 +99,7 @@ "map-props": "^1.0.0", "multireducer": "^2.0.0", "piping": "^0.3.0", - "pm2": "2.0.18", + "pm2": "^2.0.18", "pretty-error": "^1.2.0", "react": "^0.14.2", "react-bootstrap": "^0.28.1",