-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.ts
More file actions
27 lines (22 loc) · 903 Bytes
/
index.ts
File metadata and controls
27 lines (22 loc) · 903 Bytes
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
import { readConfig } from './config.ts'
import { HttpServer } from './http/server.ts'
const server = new HttpServer(await readConfig())
// node started generating diagnostic reports on SIGUSR2 at some point.
// The website already used SIGUSR2 for several years at that point.
process.report.reportOnSignal = false
process.on('SIGUSR2', function () {
server.logger.info('Received signal SIGUSR2. Reloading server.')
readConfig()
.then(async config => await server.reload(config))
.catch(server.handleUnexectedError)
})
for (const signal of ['SIGINT', 'SIGTERM', 'SIGQUIT']) {
process.on(signal, function () {
if (server.getState() === 'running') {
server.logger.info(`Received signal ${signal}. Shutting down server.`)
server.stop(signal).catch(server.handleUnexectedError)
server.finalize().catch(server.handleUnexectedError)
}
})
}
await server.start()