{"action":"created","issue":{"url":"https://api.github.com/repos/godaddy/terminus/issues/71","repository_url":"https://api.github.com/repos/godaddy/terminus","labels_url":"https://api.github.com/repos/godaddy/terminus/issues/71/labels{/name}","comments_url":"https://api.github.com/repos/godaddy/terminus/issues/71/comments","events_url":"https://api.github.com/repos/godaddy/terminus/issues/71/events","html_url":"https://github.com/godaddy/terminus/issues/71","id":351692914,"node_id":"MDU6SXNzdWUzNTE2OTI5MTQ=","number":71,"title":"Express server shutting down immediately on 'SIGINT' signal in MacOS or Linux, onSignal callback not called ","user":{"login":"siddkar","id":35924946,"node_id":"MDQ6VXNlcjM1OTI0OTQ2","avatar_url":"https://avatars1.githubusercontent.com/u/35924946?v=4","gravatar_id":"","url":"https://api.github.com/users/siddkar","html_url":"https://github.com/siddkar","followers_url":"https://api.github.com/users/siddkar/followers","following_url":"https://api.github.com/users/siddkar/following{/other_user}","gists_url":"https://api.github.com/users/siddkar/gists{/gist_id}","starred_url":"https://api.github.com/users/siddkar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/siddkar/subscriptions","organizations_url":"https://api.github.com/users/siddkar/orgs","repos_url":"https://api.github.com/users/siddkar/repos","events_url":"https://api.github.com/users/siddkar/events{/privacy}","received_events_url":"https://api.github.com/users/siddkar/received_events","type":"User","site_admin":false},"labels":[{"id":764891722,"node_id":"MDU6TGFiZWw3NjQ4OTE3MjI=","url":"https://api.github.com/repos/godaddy/terminus/labels/bug","name":"bug","color":"ee0701","default":true},{"id":764891728,"node_id":"MDU6TGFiZWw3NjQ4OTE3Mjg=","url":"https://api.github.com/repos/godaddy/terminus/labels/question","name":"question","color":"cc317c","default":true}],"state":"open","locked":false,"assignee":{"login":"gergelyke","id":2174968,"node_id":"MDQ6VXNlcjIxNzQ5Njg=","avatar_url":"https://avatars0.githubusercontent.com/u/2174968?v=4","gravatar_id":"","url":"https://api.github.com/users/gergelyke","html_url":"https://github.com/gergelyke","followers_url":"https://api.github.com/users/gergelyke/followers","following_url":"https://api.github.com/users/gergelyke/following{/other_user}","gists_url":"https://api.github.com/users/gergelyke/gists{/gist_id}","starred_url":"https://api.github.com/users/gergelyke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gergelyke/subscriptions","organizations_url":"https://api.github.com/users/gergelyke/orgs","repos_url":"https://api.github.com/users/gergelyke/repos","events_url":"https://api.github.com/users/gergelyke/events{/privacy}","received_events_url":"https://api.github.com/users/gergelyke/received_events","type":"User","site_admin":false},"assignees":[{"login":"gergelyke","id":2174968,"node_id":"MDQ6VXNlcjIxNzQ5Njg=","avatar_url":"https://avatars0.githubusercontent.com/u/2174968?v=4","gravatar_id":"","url":"https://api.github.com/users/gergelyke","html_url":"https://github.com/gergelyke","followers_url":"https://api.github.com/users/gergelyke/followers","following_url":"https://api.github.com/users/gergelyke/following{/other_user}","gists_url":"https://api.github.com/users/gergelyke/gists{/gist_id}","starred_url":"https://api.github.com/users/gergelyke/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gergelyke/subscriptions","organizations_url":"https://api.github.com/users/gergelyke/orgs","repos_url":"https://api.github.com/users/gergelyke/repos","events_url":"https://api.github.com/users/gergelyke/events{/privacy}","received_events_url":"https://api.github.com/users/gergelyke/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-08-17T18:19:45Z","updated_at":"2018-08-17T19:35:12Z","closed_at":null,"author_association":"NONE","body":"Hi Team,\r\nAs mentioned in the docs, implemented terminus in my app.\r\nIt's working fine in Windows platform and (onSignal callback is invoked) all my connections are getting shutdown gracefully on the signal of SIGINT.\r\nWhile implementing the same in Linux and MacOS, when I fire a SIGINT from terminal it immediately terminates the application and doesn't invoke the onSignal callback for graceful shutdown of connections.\r\n\r\nPFB the config code which I created.\r\n\r\n```javascript\r\nimport { logger } from './pino.config';\r\nimport mongoose from './db.config';\r\nimport redisClient from './redis.config';\r\n const logError = (from, code, error) => (logger.error({ from, code, error }));\r\n const logInfo = connectionName => (logger.info({ message: `Connection with ${connectionName} shutdown gracefully!!!` }));\r\n const timeout = 1000;\r\n const signals = ['SIGINT', 'SIGTERM', 'SIGHUP'];\r\n const mongoHealthCheck = () => {\r\n    const { readyState } = mongoose.connection;\r\n    if (readyState === 0 || readyState === 3) {\r\n        return 'ERR_CONNECTING_TO_MONGO';\r\n    }\r\n    if (readyState === 2) {\r\n        return 'CONNECTING_TO_MONGO';\r\n    }\r\n    return 'CONNECTED_TO_MONGO';\r\n};\r\n const redisHealthCheck = () => (redisClient.connected ? 'CONNECTED_TO_REDIS' : 'ERR_CONNECTING_TO_REDIS');\r\n const onHealthCheck = async () => {\r\n    const mongoHealth = mongoHealthCheck();\r\n    const redisHealth = redisHealthCheck();\r\n    return {\r\n        mongoHealth,\r\n        redisHealth,\r\n    };\r\n};\r\n const shutdownRedis = connectionName => redisClient.quit()\r\n    .then(() => logInfo(connectionName))\r\n    .catch(err => logError('terminus.config.shutdownRedis', 'ERR_DISCONNECTING_FROM_REDIS', err));\r\n const shutdownMongoose = connectionName => mongoose.connection.close(false)\r\n    .then(() => logInfo(connectionName))\r\n    .catch(err => logError('terminus.config.shutdownMongoose', 'ERR_DISCONNECTING_FROM_MONGO', err));\r\n const onSignal = () => Promise.all([shutdownRedis('Redis'), shutdownMongoose('Mongo')])\r\n    .then(() => logger.info({ message: 'All services gracefully shutdown' }))\r\n    .catch(err => logError('terminus.config.onSignal', 'ERR_DISCONNECTING_SERVICES', err));\r\n const beforeShutdown = () => new Promise((resolve) => {\r\n    setTimeout(resolve, 5000);\r\n});\r\n const healthChecks = {\r\n    '/healthcheck': onHealthCheck,\r\n};\r\n const terminusConfig = {\r\n    timeout,\r\n    healthChecks,\r\n    signals,\r\n    beforeShutdown,\r\n    onSignal,\r\n};\r\nexport default terminusConfig;\r\n```\r\n\r\nCan anyone help me with it.\r\nThanks & Regards,\r\nSiddharth"},"comment":{"url":"https://api.github.com/repos/godaddy/terminus/issues/comments/413967817","html_url":"https://github.com/godaddy/terminus/issues/71#issuecomment-413967817","issue_url":"https://api.github.com/repos/godaddy/terminus/issues/71","id":413967817,"node_id":"MDEyOklzc3VlQ29tbWVudDQxMzk2NzgxNw==","user":{"login":"KP1422","id":32662151,"node_id":"MDQ6VXNlcjMyNjYyMTUx","avatar_url":"https://avatars2.githubusercontent.com/u/32662151?v=4","gravatar_id":"","url":"https://api.github.com/users/KP1422","html_url":"https://github.com/KP1422","followers_url":"https://api.github.com/users/KP1422/followers","following_url":"https://api.github.com/users/KP1422/following{/other_user}","gists_url":"https://api.github.com/users/KP1422/gists{/gist_id}","starred_url":"https://api.github.com/users/KP1422/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/KP1422/subscriptions","organizations_url":"https://api.github.com/users/KP1422/orgs","repos_url":"https://api.github.com/users/KP1422/repos","events_url":"https://api.github.com/users/KP1422/events{/privacy}","received_events_url":"https://api.github.com/users/KP1422/received_events","type":"User","site_admin":false},"created_at":"2018-08-17T19:35:12Z","updated_at":"2018-08-17T19:35:12Z","author_association":"NONE","body":"Hi i too am facing the same issue in Ubuntu, SIGINT should get called when i hot Ctrl + C, but it doesn;t. \r\nPlease help in case there is a fix for the same."}}
{"actor":{"display_login":"KP1422"}}