Browse Source

[feat] added pm2 configs & .env for port

master
Maielo 3 years ago
parent
commit
193cfcc412
6 changed files with 2570 additions and 0 deletions
  1. 1
    0
      .env.development
  2. 2535
    0
      package-lock.json
  3. 1
    0
      package.json
  4. 17
    0
      pm2.json
  5. 10
    0
      pm2production.json
  6. 6
    0
      src/index.ts

+ 1
- 0
.env.development View File

@@ -0,0 +1 @@
1
+PORT=3000

+ 2535
- 0
package-lock.json
File diff suppressed because it is too large
View File


+ 1
- 0
package.json View File

@@ -9,6 +9,7 @@
9 9
     "@typescript-eslint/eslint-plugin": "4.16.1",
10 10
     "@typescript-eslint/parser": "4.16.1",
11 11
     "debug": "4.3.1",
12
+    "dotenv": "^10.0.0",
12 13
     "eslint": "7.21.0",
13 14
     "eslint-config-prettier": "8.1.0",
14 15
     "eslint-plugin-prettier": "3.3.1",

+ 17
- 0
pm2.json View File

@@ -0,0 +1,17 @@
1
+{
2
+  "name": "webex-collab-dev",
3
+  "script": "./dist/index.js",
4
+  "watch": ["src/"],
5
+  "ignore_watch": [
6
+    "node_modules",
7
+    "public"
8
+  ],
9
+  "autorestart": false,
10
+  "exec_mode": "fork_mode",
11
+  "instances": 1,
12
+  "env": {
13
+    "NODE_ENV": "development",
14
+    "TZ": "Europe/London"
15
+  },
16
+  "node_args": ["--inspect=127.0.0.1:9320"]
17
+}

+ 10
- 0
pm2production.json View File

@@ -0,0 +1,10 @@
1
+{
2
+  "name": "webex-collab",
3
+  "script": "./dist/index.js",
4
+  "autorestart": true,
5
+  "exec_mode": "fork_mode",
6
+  "instances": 1,
7
+  "env": {
8
+    "NODE_ENV": "production"
9
+  }
10
+}

+ 6
- 0
src/index.ts View File

@@ -7,6 +7,12 @@ const serverDebug = debug("server");
7 7
 const ioDebug = debug("io");
8 8
 const socketDebug = debug("socket");
9 9
 
10
+require("dotenv").config(
11
+  process.env.NODE_ENV !== "development"
12
+    ? { path: ".env.production" }
13
+    : { path: ".env.development" },
14
+);
15
+
10 16
 const app = express();
11 17
 const port = process.env.PORT || 80; // default port to listen
12 18
 

Loading…
Cancel
Save