-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.ts
64 lines (51 loc) · 1.19 KB
/
start.ts
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
require('dotenv').config()
import cluster from 'cluster'
import config from './config'
import registrar from './registrar'
import runner from './runner'
// REGISTER::MODULE-ALIASES
if (config.moduleAliases) {
registrar.moduleAliases(config.moduleAliases)
}
// REGISTER::GLOBAL-VARIABLES
if (config.global) {
registrar.globalVariables(config.global)
}
// REGISTER::GLOBAL-STRUCTS
if (config.structs && config.structs.setGlobal) {
registrar.globalStructs(config.structs)
}
void (async () => {
// RUN-HOOK::INIT
if (config.init) {
await config.init(config)
}
// IS::MASTER
if (cluster.isPrimary) {
// IS::MULTIPROCESSING
if (config.server.multiprocessing) {
// RUN::MASTER
await runner.master(config)
}
// IS::SINGLE-PROCESS
else {
// RUN::WORKER
await runner.worker(config)
}
// RUN::CRON
if (config.cron) {
runner.cron(config.cron)
}
// RUN::PROCESSES
if (config.processes) {
runner.processes(config.processes).catch((err: any) => console.error(err))
}
// RUN::PRINT-APP-INFO
runner.printAppInfo(config)
}
// IS::WORKER
else {
// RUN::WORKER
await runner.worker(config)
}
})()