Skip to content

Commit

Permalink
Merge pull request #1 from Icenium/kerezov/graceful-shutdown
Browse files Browse the repository at this point in the history
Initial implementation
  • Loading branch information
Mitko-Kerezov authored Oct 28, 2019
2 parents ea9e17a + 40fd745 commit f1604ff
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@ build/Release
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# Optional npm cache directory
.npm

Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2019 Telerik AppBuilder
Copyright (c) 2019 Progress Software Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 22 additions & 0 deletions index.js
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;
21 changes: 21 additions & 0 deletions package.json
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"
}
8 changes: 8 additions & 0 deletions typings/interfaces.d.ts
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;
}

0 comments on commit f1604ff

Please sign in to comment.