dygapp 6 vuotta sitten
vanhempi
commit
dc09f7251b
3 muutettua tiedostoa jossa 37 lisäystä ja 9 poistoa
  1. 17 0
      ecosystem.config.js
  2. 11 9
      package.json
  3. 9 0
      server.js

+ 17 - 0
ecosystem.config.js

@@ -0,0 +1,17 @@
+'use strict';
+
+const app = 'service-tmpl';
+module.exports = {
+  apps: [{
+    name: app, // 应用名称
+    script: './server.js', // 实际启动脚本
+    out: `./logs/${app}.log`,
+    error: `./logs/${app}.err`,
+    watch: [ // 监控变化的目录,一旦变化,自动重启
+      'app', 'config',
+    ],
+    env: {
+      NODE_ENV: 'production', // 环境参数,当前指定为生产环境
+    },
+  }],
+};

+ 11 - 9
package.json

@@ -7,18 +7,18 @@
     "framework": "naf-framework-mongoose"
   },
   "dependencies": {
-    "egg": "^2.5.0",
-    "egg-scripts": "^2.5.1",
-    "naf-framework-mongoose": "^0.2.1"
+    "egg": "^2.14.1",
+    "egg-scripts": "^2.10.0",
+    "naf-framework-mongoose": "^0.5.17"
   },
   "devDependencies": {
     "autod": "^3.0.1",
     "autod-egg": "^1.1.0",
-    "egg-bin": "^4.5.0",
-    "egg-ci": "^1.8.0",
-    "egg-mock": "^3.16.0",
-    "eslint": "^4.19.1",
-    "eslint-config-egg": "^7.0.0",
+    "egg-bin": "^4.9.0",
+    "egg-ci": "^1.10.0",
+    "egg-mock": "^3.20.1",
+    "eslint": "^5.9.0",
+    "eslint-config-egg": "^7.1.0",
     "eslint-config-egg-naf": "0.0.3",
     "webstorm-disable-index": "^1.2.0"
   },
@@ -35,7 +35,9 @@
     "cov": "egg-bin cov",
     "lint": "eslint .",
     "ci": "npm run lint && npm run cov",
-    "autod": "autod"
+    "autod": "autod",
+    "pm2": "pm2 start",
+    "restart": "pm2 restart service-tmpl"
   },
   "ci": {
     "version": "8"

+ 9 - 0
server.js

@@ -0,0 +1,9 @@
+
+// eslint-disable-next-line strict
+const egg = require('egg');
+
+const workers = Number(process.argv[2] || require('os').cpus().length);
+egg.startCluster({
+  workers,
+  baseDir: __dirname,
+});