-
Notifications
You must be signed in to change notification settings - Fork 304
/
ecosystem.config.js
197 lines (192 loc) · 3.82 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
* PM2 configuration file
*/
require('dotenv').config();
const os = require('os');
const dev = process.env.NODE_ENV === 'development';
const prod = process.env.NODE_ENV === 'production';
let arr = [
// Services in non-backend groups are deployed separately
{
// Proxy requests to Steam API
name: 'proxy',
group: 'proxy',
},
{
// Load old matches into storage
name: 'backfill',
group: 'backfill',
},
{
// Alternative way of getting matches if GetMatchHistoryBySequenceNum is broken
name: 'backupscanner',
group: 'disabled',
},
{
name: 'web',
group: 'backend',
exec_mode: prod ? 'cluster' : undefined,
instances: prod ? os.cpus().length : undefined,
},
// One local instance of retriever for getting player profiles since this isn't rate limited
{
name: 'retriever',
group: 'backend',
env: {
// Clear registry host since we don't need to register local service
SERVICE_REGISTRY_HOST: '',
},
},
{
// Requests and inserts replay parse data. Note this is different from parseServer which is in Java and runs externally
name: 'parser',
group: 'backend',
},
{
name: 'fullhistory',
group: 'backend',
},
{
name: 'apiadmin',
group: 'backend',
},
{
name: 'mmr',
group: 'backend',
},
{
name: 'profiler',
group: 'backend',
},
{
name: 'scanner',
group: 'backend',
},
{
// Secondary scanner that runs behind and picks up matches previously missing
name: 'scanner2',
name_override: 'scanner',
group: 'backend',
env: {
SCANNER_OFFSET: '50000',
},
},
{
name: 'autocache',
group: 'backend',
instances: 2,
},
{
name: 'autofullhistory',
group: 'backend',
},
{
name: 'monitor',
group: 'backend',
},
{
name: 'gcdata',
group: 'backend',
},
{
name: 'buildsets',
group: 'backend',
},
{
name: 'cosmetics',
group: 'backend',
},
{
name: 'distributions',
group: 'backend',
},
{
name: 'heroes',
group: 'backend',
},
{
name: 'items',
group: 'backend',
},
{
name: 'leagues',
group: 'backend',
},
{
name: 'livegames',
group: 'backend',
},
{
name: 'proplayers',
group: 'backend',
},
{
name: 'teams',
group: 'backend',
},
{
name: 'scenarios',
group: 'backend',
},
{
name: 'cleanup',
group: 'backend',
},
{
name: 'counts',
group: 'backend',
},
{
name: 'syncSubs',
group: 'backend',
},
{
name: 'archiver',
group: 'backend',
instances: 4,
},
{
name: 'reconcile',
group: 'backend',
},
// Requires the gcloud CLI to be installed
// We could write this in JS to use the REST API, authenticating using metadata server credentials
// {
// name: 'cycler',
// group: 'backend',
// script: 'scripts/cycler.py',
// interpreter: 'python3',
// },
];
// If GROUP is set filter to only the matching group
arr = arr.filter(
(app) => !process.env.GROUP || app.group === process.env.GROUP,
);
const apps = arr.map((app) => {
// In production, we can use the built files directly
// This makes the pm2 memory metrics work
const prodScript = `build/index.js`;
const devScript = `index.ts`;
const script = prod ? prodScript : devScript;
return {
...app,
watch: dev ? true : false,
ignore_watch: ['.git', 'node_modules', 'build', 'json'],
log_date_format: 'YYYY-MM-DDTHH:mm:ss',
exec_mode: app.exec_mode ?? 'fork',
instances: app.instances ?? 1,
script: app.script ?? script,
interpreter:
app.interpreter ??
(script.endsWith('.ts') || script.endsWith('.mts')
? 'node_modules/.bin/tsx'
: undefined),
env: {
...app.env,
ROLE: app.name_override ?? app.name,
},
};
});
module.exports = {
apps,
};