-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathecosystem.config.js
More file actions
75 lines (72 loc) · 2.24 KB
/
Copy pathecosystem.config.js
File metadata and controls
75 lines (72 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
"use strict";
/* PM2 process definitions, one app per deploy environment. App names are
"<prefix>-<env>" and the Makefile's deploy-<env> targets select one with
`pm2 start|reload ecosystem.config.js --only <name>` — keep the names in sync
with PM2_APP_PREFIX in the Makefile.
NODE_ENV values here ("dev" / "staging" / "production") must stay inside the
choices list that getEnv() validates in libs/config/src/env/index.ts, or the
process exits at boot. The Swagger/Scalar docs at /docs are gated separately
by API_DOCS_ENABLED, which comes from the .env file below.
env_file loads .env from the deploy directory; per-environment values are
supplied by that file, not by this config. Only NODE_ENV is set here. */
module.exports = {
apps: [
{
name: "clean-nest-prisma-pg-dev",
script: "dist/main.js",
instances: 1,
exec_mode: "fork",
env: {
NODE_ENV: "dev",
},
env_file: ".env",
out_file: "logs/dev-out.log",
error_file: "logs/dev-error.log",
log_date_format: "YYYY-MM-DD HH:mm:ss Z",
merge_logs: true,
autorestart: true,
watch: false,
max_memory_restart: "2G",
},
{
name: "clean-nest-prisma-pg-staging",
script: "dist/main.js",
instances: 1,
exec_mode: "fork",
env: {
NODE_ENV: "staging",
},
env_file: ".env",
out_file: "logs/staging-out.log",
error_file: "logs/staging-error.log",
log_date_format: "YYYY-MM-DD HH:mm:ss Z",
merge_logs: true,
autorestart: true,
watch: false,
max_memory_restart: "2G",
},
{
/* Cluster mode is safe here because nothing in this codebase runs on a
timer — every instance only serves requests. If you add scheduled work
(@nestjs/schedule or a queue producer that self-triggers), it will run
once per instance unless you guard it with a lock. */
name: "clean-nest-prisma-pg-production",
script: "dist/main.js",
instances: "max",
exec_mode: "cluster",
env: {
NODE_ENV: "production",
},
env_file: ".env",
out_file: "logs/production-out.log",
error_file: "logs/production-error.log",
log_date_format: "YYYY-MM-DD HH:mm:ss Z",
merge_logs: true,
autorestart: true,
watch: false,
max_memory_restart: "4G",
kill_timeout: 5000,
listen_timeout: 30000,
},
],
};