Skip to content

Commit

Permalink
Use wrapper.exit to perform /shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
gaberudy committed Jan 21, 2025
1 parent 03c5fbe commit 27ac8c8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/node/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { PluginAPI } from "../plugin"
import { CoderSettings, SettingsProvider } from "../settings"
import { UpdateProvider } from "../update"
import { getMediaMime, paths } from "../util"
import { wrapper } from "../wrapper"
import * as apps from "./apps"
import * as domainProxy from "./domainProxy"
import { errorHandler, wsErrorHandler } from "./errors"
Expand Down Expand Up @@ -172,8 +173,9 @@ export const register = async (app: App, args: DefaultedArgs): Promise<Disposabl

if (args["allow-shutdown"] ) {
app.router.use("/shutdown", async (req, res) => {
res.send(`Shutting down...`)
process.kill(process.pid, "SIGTERM")
redirect(req, res, "/", {})
logger.warn("Shutting down due to /shutdown")
setTimeout(() => wrapper.exit(0), 10)
})
} else {
app.router.use("/shutdown", (req, res) => redirect(req, res, "/", {}))
Expand Down

0 comments on commit 27ac8c8

Please sign in to comment.