浏览代码

Merge pull request #162 from LEXUGE/patch-1

Add support for SIGINT and SIGTERM handling
RobinLinus 4 年之前
父节点
当前提交
130f5391f8
共有 1 个文件被更改,包括 13 次插入0 次删除
  1. 13 0
      server/index.js

+ 13 - 0
server/index.js

@@ -1,3 +1,16 @@
+var process = require('process')
+// Handle SIGINT
+process.on('SIGINT', () => {
+  console.info("SIGINT Received, exiting...")
+  process.exit(0)
+})
+
+// Handle SIGTERM
+process.on('SIGTERM', () => {
+  console.info("SIGTERM Received, exiting...")
+  process.exit(0)
+})
+
 const parser = require('ua-parser-js');
 const { uniqueNamesGenerator, animals, colors } = require('unique-names-generator');