-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
executable file
·50 lines (37 loc) · 1 KB
/
index.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
#!/usr/bin/env node
const {existsSync, unlinkSync, chmodSync} = require("fs")
const createServer = require("./server")
const prepare = require("./prepare")
const config = require("./config")
const domains = require("./domains")
config.womginx ??= []
config.redirects ??= {}
config.blacklist ??= []
const context = {
config,
domains,
root: __dirname
}
prepare(context)
console.log("Starting Corrosion gateway...")
const server = createServer(config)
const socketPath = "/tmp/corrosion.socket"
const unlinkForce = () => {
if (existsSync(socketPath))
unlinkSync(socketPath)
}
unlinkForce()
process
.on("SIGINT", () => {
console.log("\nStopping the Corrosion gateway...")
unlinkForce()
process.exit()
})
.on("uncaughtExceptionMonitor", () => {
console.log("\nStopping from an uncaught exception!")
unlinkForce()
process.exit(1)
})
server.listen(socketPath)
chmodSync(socketPath, "777")
console.log("Corrosion gateway has started!")