-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): shutdown daemon via message so it can clean itself up
- Loading branch information
1 parent
35a33ae
commit 5e43458
Showing
8 changed files
with
102 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const FORCE_SHUTDOWN = 'FORCE_SHUTDOWN' as const; | ||
|
||
export type HandleForceShutdownMessage = { | ||
type: typeof FORCE_SHUTDOWN; | ||
}; | ||
|
||
export function isHandleForceShutdownMessage( | ||
message: unknown | ||
): message is HandleForceShutdownMessage { | ||
return ( | ||
typeof message === 'object' && | ||
message !== null && | ||
'type' in message && | ||
message['type'] === FORCE_SHUTDOWN | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Server } from 'net'; | ||
import { handleServerProcessTermination } from './shutdown-utils'; | ||
import { openSockets } from './server'; | ||
|
||
export async function handleForceShutdown(server: Server) { | ||
setTimeout(async () => { | ||
await handleServerProcessTermination({ | ||
server, | ||
reason: 'Request to shutdown', | ||
sockets: openSockets, | ||
}); | ||
}); | ||
return { | ||
description: 'Shutdown initiated', | ||
response: '{}', | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters