-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpm2.config.js
More file actions
41 lines (39 loc) · 1.01 KB
/
pm2.config.js
File metadata and controls
41 lines (39 loc) · 1.01 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
const PROFILES = {
local: {
instances: 1,
node_args: '--trace-warnings',
},
dev: {
instances: 2,
node_args: '--trace-warnings',
},
production: {
instances: 4,
},
}
function createPm2Config() {
const profile = process.env.NEXT_PUBLIC_ENV
const envConfig = PROFILES[profile]
return {
apps: [
{
name: 'node-web-server',
script: 'node_modules/next/dist/bin/next',
args: 'start',
cwd: './',
interpreter: 'node',
exec_mode: 'cluster',
max_restarts: 5,
min_uptime: 5000,
log_date_format: '<YYYY-MM-DD HH:mm:ss>',
env: {
NODE_ENV: 'production',
NEXT_PUBLIC_ENV: profile,
},
...envConfig,
},
],
}
}
console.log(JSON.stringify(createPm2Config(), null, '\t'))
module.exports = createPm2Config()