This repository has been archived by the owner on Jan 16, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpm2.config.cjs
270 lines (250 loc) · 6.11 KB
/
pm2.config.cjs
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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
//
// frontend
//
const frontendAppBase = {
script: 'npm',
exp_backoff_restart_delay: 100,
env: {
HUSKY: 0,
DOPPLER_PROJECT: 'web',
DOPPLER_CONFIG: 'prd',
},
};
const frontendApps = [
{
...frontendAppBase,
name: 'web',
args: 'run start -w apps-frontend/web',
env: {
...frontendAppBase.env,
PORT: 3000,
},
},
{
...frontendAppBase,
name: 'web-secondary',
args: 'run start -w apps-frontend/web',
env: {
...frontendAppBase.env,
PORT: 3100,
},
},
];
//
// backend
//
const backendAppBase = {
script: 'npm',
exp_backoff_restart_delay: 100,
env: {
HUSKY: 0,
DOPPLER_PROJECT: 'backend',
DOPPLER_CONFIG: 'prd_fish_server',
PORT: 0, // system will assign a random port
},
};
const backendApps = [
{
...backendAppBase,
name: 'back',
args: 'run start -w apps-backend/back',
cron_restart: '0 */4 * * *',
env: {
...backendAppBase.env,
PORT: 3001,
},
},
{
...backendAppBase,
name: 'back-secondary',
args: 'run start -w apps-backend/back',
cron_restart: '2 */4 * * *',
env: {
...backendAppBase.env,
PORT: 3101,
},
},
{
...backendAppBase,
name: 'bot',
args: 'run start -w apps-backend/bot',
cron_restart: '4 */4 * * *',
},
{
...backendAppBase,
name: 'copy',
args: 'run start -w apps-backend/copy',
cron_restart: '6 */4 * * *',
},
{
...backendAppBase,
name: 'cron',
args: 'run start -w apps-backend/cron',
cron_restart: '8 */4 * * *',
},
{
...backendAppBase,
name: 'gate',
args: 'run start -w apps-backend/gate',
cron_restart: '10 */4 * * *',
env: {
...backendAppBase.env,
PORT: 8001,
},
},
{
...backendAppBase,
name: 'head-ctrader',
args: 'run start -w apps-backend/head-ctrader',
cron_restart: '12 */4 * * *',
},
{
...backendAppBase,
name: 'head-meta',
args: 'run start -w apps-backend/head-meta',
cron_restart: '14 */4 * * *',
},
{
...backendAppBase,
name: 'mon',
args: 'run start -w apps-backend/mon',
cron_restart: '16 */4 * * *',
env: {
...backendAppBase.env,
PORT: 8000,
DRY_RUN: true,
},
},
{
...backendAppBase,
name: 'pay',
args: 'run start -w apps-backend/pay',
cron_restart: '18 */4 * * *',
env: {
...backendAppBase.env,
PORT: 8020,
},
},
{
...backendAppBase,
name: 'pup',
args: 'run start -w apps-backend/pup',
cron_restart: '20 */4 * * *',
},
{
...backendAppBase,
name: 'spot-ctrader',
args: 'run start -w apps-backend/spot-ctrader',
cron_restart: '22 */4 * * *',
},
{
...backendAppBase,
name: 'spot-meta',
args: 'run start -w apps-backend/spot-meta',
cron_restart: '24 */4 * * *',
},
{
...backendAppBase,
name: 'spot-ctrader-poll',
args: 'run start -w apps-backend/spot-ctrader',
cron_restart: '26 */4 * * *',
env: {
...backendAppBase.env,
TYPE_ID: 'spot-ctrader-icmarkets-poll',
SPOT_TASKS: 'poll',
WATCH_PATTERN: '^(AUDCAD|AUDCHF|AUDJPY|AUDNZD|AUDUSD|CADCHF|CADJPY|CHFJPY|EURAUD|EURCAD|EURCHF|EURGBP|EURJPY|EURNZD|EURUSD|GBPAUD|GBPCAD|GBPCHF|GBPJPY|GBPNZD|GBPUSD|NZDCAD|NZDCHF|NZDJPY|NZDUSD|USDCAD|USDCHF|USDJPY|XAGUSD|XAUUSD)$',
},
},
{
...backendAppBase,
name: 'spot-meta-poll',
args: 'run start -w apps-backend/spot-meta',
cron_restart: '28 */4 * * *',
env: {
...backendAppBase.env,
TYPE_ID: 'spot-meta-exness-poll',
SPOT_TASKS: 'poll',
WATCH_PATTERN: '^(AUDCAD|AUDCHF|AUDJPY|AUDNZD|AUDUSD|CADCHF|CADJPY|CHFJPY|EURAUD|EURCAD|EURCHF|EURGBP|EURJPY|EURNZD|EURUSD|GBPAUD|GBPCAD|GBPCHF|GBPJPY|GBPNZD|GBPUSD|NZDCAD|NZDCHF|NZDJPY|NZDUSD|USDCAD|USDCHF|USDJPY|XAGUSD|XAUUSD)$',
},
},
];
const apps = [...backendApps, ...frontendApps];
//
// deploy
//
const deployConfigBase = {
user: 'marco',
repo: '[email protected]:fishprovider/main.git',
ref: 'tags/release',
'pre-deploy-local': 'git tag release -f; git push origin release -f',
'pre-deploy': 'git reset --hard; git clean -fd; git tag -d release secondary || echo 1',
'post-deploy': 'git rev-parse HEAD',
};
const deployConfigFishServer = {
...deployConfigBase,
host: 'fish-server.fishprovider.com',
ssh_options: 'Port=1503',
};
const deploy = {
localhost: {
...deployConfigBase,
host: 'localhost',
path: '/Users/marco/pm2-apps/fishprovider',
},
fishWeb: { // web
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-web',
},
fishBack: { // back
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-back',
},
fishPrice: { // spot-*
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-price',
},
fishOrder: { // head-*
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-order',
},
fishBot: { // bot, copy
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-bot',
},
fishPay: { // pay
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-pay',
},
fishCron: { // cron, mon, gate
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-cron',
},
fishSecondary: { // web-secondary, back-secondary
...deployConfigFishServer,
path: '/home/marco/work/pm2-apps/fishprovider-secondary',
ref: 'tags/secondary',
'pre-deploy-local': 'git tag secondary -f; git push origin secondary -f',
},
};
module.exports = {
apps,
deploy,
};
/* Examples:
./deploy.sh web frontend fishWeb
./deploy.sh back backend fishBack
./deploy.sh spot-ctrader backend fishPrice
./deploy.sh spot-meta backend fishPrice
./deploy.sh spot-ctrader-poll backend fishPrice
./deploy.sh spot-meta-poll backend fishPrice
./deploy.sh head-ctrader backend fishOrder
./deploy.sh head-meta backend fishOrder
./deploy.sh bot backend fishBot
./deploy.sh copy backend fishBot
./deploy.sh pay backend fishPay
./deploy.sh cron backend fishCron
./deploy.sh gate backend fishCron
./deploy.sh mon backend fishCron
./deploy-secondary.sh web frontend
./deploy-secondary.sh back backend
*/