Skip to content

Commit 27ac8c8

Browse files
committed
Use wrapper.exit to perform /shutdown
1 parent 03c5fbe commit 27ac8c8

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/node/routes/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { PluginAPI } from "../plugin"
1717
import { CoderSettings, SettingsProvider } from "../settings"
1818
import { UpdateProvider } from "../update"
1919
import { getMediaMime, paths } from "../util"
20+
import { wrapper } from "../wrapper"
2021
import * as apps from "./apps"
2122
import * as domainProxy from "./domainProxy"
2223
import { errorHandler, wsErrorHandler } from "./errors"
@@ -172,8 +173,9 @@ export const register = async (app: App, args: DefaultedArgs): Promise<Disposabl
172173

173174
if (args["allow-shutdown"] ) {
174175
app.router.use("/shutdown", async (req, res) => {
175-
res.send(`Shutting down...`)
176-
process.kill(process.pid, "SIGTERM")
176+
redirect(req, res, "/", {})
177+
logger.warn("Shutting down due to /shutdown")
178+
setTimeout(() => wrapper.exit(0), 10)
177179
})
178180
} else {
179181
app.router.use("/shutdown", (req, res) => redirect(req, res, "/", {}))

0 commit comments

Comments
 (0)