forked from TimeRainStarSky/Yunzai
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (31 loc) · 926 Bytes
/
Copy pathapp.js
File metadata and controls
31 lines (31 loc) · 926 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
28
29
30
31
switch (process.env.app_type || process.argv[2]) {
case "stop": {
const cfg = (await import("./lib/config/config.js")).default
await fetch(`http://localhost:${cfg.server.port}/exit`, {
headers: cfg.server.auth || undefined,
}).catch(() => {})
process.exit()
}
case "daemon": {
console.log("守护进程正在启动主进程")
const { spawnSync } = await import("node:child_process")
while (
spawnSync(process.argv[0], [process.argv[1], "start", ...process.argv.slice(2)], {
stdio: "inherit",
}).status !== 255
)
console.log("守护进程正在重启主进程")
console.log("守护进程已停止")
process.exit()
}
case "pm2":
global.start_type = "pm2"
break
case "start":
global.start_type = "external"
break
default:
global.start_type = "internal"
}
global.Bot = new (await import("./lib/bot.js")).default()
Bot.run()