mirror of
https://github.com/unraid/api.git
synced 2026-01-02 06:30:02 -06:00
fix: rearrange exit hook to try to fix closing
This commit is contained in:
@@ -38,15 +38,6 @@ const unlinkUnixPort = () => {
|
||||
// Boot app
|
||||
void am(
|
||||
async () => {
|
||||
exitHook(() => {
|
||||
server?.close?.();
|
||||
// If port is unix socket, delete socket before exiting
|
||||
unlinkUnixPort();
|
||||
|
||||
shutdownApiEvent();
|
||||
|
||||
process.exit(0);
|
||||
});
|
||||
environment.IS_MAIN_PROCESS = true;
|
||||
|
||||
logger.debug('ENV %o', env);
|
||||
@@ -103,7 +94,15 @@ void am(
|
||||
await validateApiKeyIfPresent();
|
||||
|
||||
// On process exit stop HTTP server - this says it supports async but it doesnt seem to
|
||||
|
||||
exitHook(() => {
|
||||
server?.close?.();
|
||||
// If port is unix socket, delete socket before exiting
|
||||
unlinkUnixPort();
|
||||
|
||||
shutdownApiEvent();
|
||||
|
||||
process.exit(0);
|
||||
});
|
||||
},
|
||||
async (error: NodeJS.ErrnoException) => {
|
||||
logger.error('API-GLOBAL-ERROR %s %s', error.message, error.stack);
|
||||
|
||||
Reference in New Issue
Block a user