-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Icenium/kerezov/graceful-shutdown
Initial implementation
- Loading branch information
Showing
5 changed files
with
52 additions
and
4 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,22 @@ | ||
'use strict'; | ||
|
||
class KubernetesGracefulShutdownSignalHandler { | ||
constructor() { | ||
this.gracefulShutdown = false; | ||
} | ||
|
||
get shouldShutdownGracefully() { | ||
return this.gracefulShutdown; | ||
} | ||
|
||
installSignalHandler() { | ||
if (process.env.RUNNING_KUBERNETES) { | ||
process.on('SIGUSR1', () => { | ||
this.gracefulShutdown = true; | ||
}); | ||
} | ||
} | ||
} | ||
|
||
const kubernetesGracefulShutdownSignalHandler = new KubernetesGracefulShutdownSignalHandler(); | ||
module.exports.kubernetesGracefulShutdownSignalHandler = kubernetesGracefulShutdownSignalHandler; |
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,21 @@ | ||
{ | ||
"name": "k8s-graceful-shutdown-signal-handler", | ||
"types": "./typings/interfaces.d.ts", | ||
"version": "0.1.0", | ||
"description": "Package for managing graceful shutdown in a k8s cluster", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Icenium/k8s-graceful-shutdown-signal-handler.git" | ||
}, | ||
"keywords": [], | ||
"author": "Progress Software Corporation", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/Icenium/k8s-graceful-shutdown-signal-handler/issues" | ||
}, | ||
"homepage": "https://github.com/Icenium/k8s-graceful-shutdown-signal-handler#readme" | ||
} |
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,8 @@ | ||
interface KubernetesGracefulShutdownSignalHandler { | ||
shouldShutdownGracefully: boolean; | ||
installSignalHandler(): void; | ||
} | ||
|
||
declare module "k8s-graceful-shutdown-signal-handler" { | ||
export const kubernetesGracefulShutdownSignalHandler: KubernetesGracefulShutdownSignalHandler; | ||
} |