-
Notifications
You must be signed in to change notification settings - Fork 1
/
ecosystem.config.js
59 lines (59 loc) · 2.14 KB
/
ecosystem.config.js
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
/**
* @description pm2 configuration file.
* @example
* production mode :: pm2 start ecosystem.config.js --only prod
* development mode :: pm2 start ecosystem.config.js --only dev
*/
module.exports = {
apps: [
{
name: 'prod', // pm2 start App name
script: 'dist/server.js',
exec_mode: 'cluster', // 'cluster' or 'fork'
instance_var: 'INSTANCE_ID', // instance variable
instances: 2, // pm2 instance count
autorestart: true, // auto restart if process crash
watch: false, // files change automatic restart
ignore_watch: ['node_modules', 'logs'], // ignore files change
max_memory_restart: '1G', // restart if process use more than 1G memory
merge_logs: true, // if true, stdout and stderr will be merged and sent to pm2 log
output: './logs/access.log', // pm2 log file
error: './logs/error.log', // pm2 error log file
env: {
// environment variable
PORT: 3000,
NODE_ENV: 'production',
},
},
{
name: 'dev', // pm2 start App name
script: 'ts-node', // ts-node
args: '-r tsconfig-paths/register --transpile-only src/server.ts', // ts-node args
exec_mode: 'cluster', // 'cluster' or 'fork'
instance_var: 'INSTANCE_ID', // instance variable
instances: 2, // pm2 instance count
autorestart: true, // auto restart if process crash
watch: false, // files change automatic restart
ignore_watch: ['node_modules', 'logs'], // ignore files change
max_memory_restart: '1G', // restart if process use more than 1G memory
merge_logs: true, // if true, stdout and stderr will be merged and sent to pm2 log
output: './logs/access.log', // pm2 log file
error: './logs/error.log', // pm2 error log file
env: {
// environment variable
PORT: 3000,
NODE_ENV: 'development',
},
},
],
deploy: {
production: {
user: 'user',
host: '0.0.0.0',
ref: 'origin/master',
repo: 'git@github.com:repo.git',
path: 'dist/server.js',
'post-deploy': 'npm install && npm run build && pm2 reload ecosystem.config.js --only prod',
},
},
};