{"_id":"graceful-cluster","_rev":"8-373cd2f2ab8e136802cfb53a963ced4c","name":"graceful-cluster","description":"Gracefully restart node.js http cluster with zero downtime. Shutdown server without active inbound connections reset.","dist-tags":{"latest":"0.0.5"},"versions":{"0.0.1":{"name":"graceful-cluster","version":"0.0.1","description":"Gracefully restart node.js http cluster with zero downtime. Shutdown server without active inbound connections reset.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/itteco/graceful-cluster.git"},"keywords":["http","server","cluster","restart","shutdown","gracefully"],"license":"MIT","gitHead":"eb342b81da07a5f2ae8ea594f298a085b7b2c90c","bugs":{"url":"https://github.com/itteco/graceful-cluster/issues"},"homepage":"https://github.com/itteco/graceful-cluster#readme","_id":"graceful-cluster@0.0.1","scripts":{},"_shasum":"aa545ee78eb3a3c0711c332ea2ec047fce6cafdf","_from":".","_npmVersion":"2.15.1","_nodeVersion":"0.12.14","_npmUser":{"name":"itteco","email":"ivan@itteco.com"},"dist":{"shasum":"aa545ee78eb3a3c0711c332ea2ec047fce6cafdf","tarball":"https://registry.npmjs.org/graceful-cluster/-/graceful-cluster-0.0.1.tgz","integrity":"sha512-88Tb3kVJO5d6WsSKktSQpB3fY8wqZY6bvlZulQ93CCzBXo0C113KBOBv9ae3nvbQZNB7N4d9bSGwfc+okZzfkg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCyFXiZnAv7hXMUEJFdWd+aQWnxkKqpReFpoHVHXMHo/AIhAIdfUWNp7PFUPozYSGMv1aJggxkMQRR9M2XNtXF/3grZ"}]},"maintainers":[{"name":"itteco","email":"ivan@itteco.com"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/graceful-cluster-0.0.1.tgz_1469528599800_0.8361249035224319"}},"0.0.2":{"name":"graceful-cluster","version":"0.0.2","description":"Gracefully restart node.js http cluster with zero downtime. Shutdown server without active inbound connections reset.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/itteco/graceful-cluster.git"},"keywords":["http","server","cluster","restart","shutdown","gracefully"],"license":"MIT","gitHead":"17620f1729e2c82be2364f8ed10f1b87de26fb71","bugs":{"url":"https://github.com/itteco/graceful-cluster/issues"},"homepage":"https://github.com/itteco/graceful-cluster#readme","_id":"graceful-cluster@0.0.2","scripts":{},"_shasum":"19ce4ff25fc21c33dabc31b1d9860b2660b25871","_from":".","_npmVersion":"2.15.1","_nodeVersion":"0.12.14","_npmUser":{"name":"itteco","email":"ivan@itteco.com"},"dist":{"shasum":"19ce4ff25fc21c33dabc31b1d9860b2660b25871","tarball":"https://registry.npmjs.org/graceful-cluster/-/graceful-cluster-0.0.2.tgz","integrity":"sha512-j2aVoR3/GyAboNXoYP4+uOt6D5YcI58sUZ6IUNJygd70dUbnNO7X9YRdq2vzhr1aXTgOsHcJOmC7eVDJhXSjhA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAZXvVyY5Rdv68VDkqj/76fMraU8LLeVU1JgVUHGo/u+AiEAg6eV5qgnU6vKgv/ykoTa76RVBOGb9+CTBtOtg3H8sos="}]},"maintainers":[{"name":"itteco","email":"ivan@itteco.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/graceful-cluster-0.0.2.tgz_1484146804364_0.36981562129221857"}},"0.0.3":{"name":"graceful-cluster","version":"0.0.3","description":"Gracefully restart node.js http cluster with zero downtime. Shutdown server without active inbound connections reset.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/itteco/graceful-cluster.git"},"keywords":["http","server","cluster","restart","shutdown","gracefully"],"license":"MIT","gitHead":"b98c889585620701f25ea243e13ecfeca82fb63c","bugs":{"url":"https://github.com/itteco/graceful-cluster/issues"},"homepage":"https://github.com/itteco/graceful-cluster#readme","_id":"graceful-cluster@0.0.3","scripts":{},"_shasum":"2c3f57da3610afb28c1bbc8afaa5030dcf506bdc","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.10.0","_npmUser":{"name":"itteco","email":"ivan@itteco.com"},"dist":{"shasum":"2c3f57da3610afb28c1bbc8afaa5030dcf506bdc","tarball":"https://registry.npmjs.org/graceful-cluster/-/graceful-cluster-0.0.3.tgz","integrity":"sha512-d7i8bVohHDIjSz0LLWv27o8aeZGDerY51irfkXG0ca02osf8yPu4ASY2rFRWGAv/o86yeuJGr/mVBb/Vlozr4Q==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDv3wA4elRhBxPqmklamtdWfL8LewdONX7TXg7rdlqeMQIhANPIAhQldZQofvvM08RTdao3RNTnB/tYLf+raD2LNC05"}]},"maintainers":[{"name":"itteco","email":"ivan@itteco.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graceful-cluster-0.0.3.tgz_1496950593991_0.3776273550465703"}},"0.0.4":{"name":"graceful-cluster","version":"0.0.4","description":"Gracefully restart node.js http cluster with zero downtime. Shutdown server without active inbound connections reset.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/itteco/graceful-cluster.git"},"keywords":["http","server","cluster","restart","shutdown","gracefully"],"license":"MIT","gitHead":"30a0c07a8775ede454c0e51873d823a8171903a4","bugs":{"url":"https://github.com/itteco/graceful-cluster/issues"},"homepage":"https://github.com/itteco/graceful-cluster#readme","_id":"graceful-cluster@0.0.4","_npmVersion":"5.1.0","_nodeVersion":"8.1.2","_npmUser":{"name":"itteco","email":"ivan@itteco.com"},"dist":{"integrity":"sha512-kD6W8cDQNp5YVsERVwQd3mMA4KoMzFXUVZRQOENXAwik8vjXJf2WWYj9Diho0sdda6AmRKUQUKQ3aKsetOpX7g==","shasum":"7a26bb1e8c10eee0d616e0cdaa7b61ab5b6608bf","tarball":"https://registry.npmjs.org/graceful-cluster/-/graceful-cluster-0.0.4.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEXid27E7x/Kei0Cgy1BmWAQ6xxHqV3awKlLoehFBvKTAiEAjZycFhwV5mRxBsJ0UNkKYVFWcPJOk0OMmnkypPZplwQ="}]},"maintainers":[{"name":"itteco","email":"ivan@itteco.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graceful-cluster-0.0.4.tgz_1499975390251_0.7309899539686739"}},"0.0.5":{"name":"graceful-cluster","version":"0.0.5","description":"Gracefully restart node.js http cluster with zero downtime. Shutdown server without active inbound connections reset.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/itteco/graceful-cluster.git"},"keywords":["http","server","cluster","restart","shutdown","gracefully"],"license":"MIT","gitHead":"e05cf15e2b622d9b34dbccc5b099634a94bc7dc0","bugs":{"url":"https://github.com/itteco/graceful-cluster/issues"},"homepage":"https://github.com/itteco/graceful-cluster#readme","_id":"graceful-cluster@0.0.5","_npmVersion":"5.1.0","_nodeVersion":"8.1.2","_npmUser":{"name":"itteco","email":"ivan@itteco.com"},"dist":{"integrity":"sha512-X3c/3MNJ2CZvSZ3sMco3HWqSBJBNiAyrNbycEj4NJpvRc7/QLI0nOi3d2MaXDMWXoenlk+Xsazwr2RMT/hHcZg==","shasum":"fe45cded3a2e216c3ed23404fe896e877c950e57","tarball":"https://registry.npmjs.org/graceful-cluster/-/graceful-cluster-0.0.5.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEImkj1N8V5ZCQn7GuFukhgzcUdrQLt/IeoXhK0h1GrcAiBCwZywLq2KQDhY28+n9iSAnU6QiwRt+bgoW1pd6PO/KA=="}]},"maintainers":[{"name":"itteco","email":"ivan@itteco.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/graceful-cluster-0.0.5.tgz_1500029902348_0.10555730969645083"}}},"readme":"# Graceful cluster\n\nInstall:\n\n    npm install graceful-cluster\n    \n## How to use\n\n### 1. Enable graceful server shutdown\n\nThis patch will prevent active connections reset when server receives `SIGKILL` or `SIGTERM`. Idle (keep-alive) inbound connections without active requests will be destroyed.\n \nExample 'server.js':\n\n```js\n// Example server with 'express'.\nvar express = require('express');\nvar app = express();\nvar listener = app.listen(8000);\n\nvar GracefulServer = require('graceful-cluster').GracefulServer;\nvar gracefulServer = new GracefulServer({\n    server: listener,\n    shutdownTimeout: 10 * 1000,             // 10 sec.\n});\n```\n    \nGracefulServer options description:\n\n| option                   | info\n| ------------------------ | ---\n|`log`                     | function, custom log function, `console.log` used by default.\n|`server`                  | required, http server instance.\n|`shutdownTimeout`         | ms, force worker shutdown on `SIGTERM` timeout. Defaults to 5000ms.\n \nAlso you can initiate graceful shutdown when needed:\n\n```js\ngracefulServer.shutdown();\n```\n\n### 2. Use simplified cluster initialization\n\nThis cluster wrapper will send `SIGTERM` signal to workers and wait till they finished all requests.\n\nAlso it can gracefully restart all workers one by one with zero cluster downtime on some conditions:\n\n  1. Worker memory used.\n  2. Worker time online.\n  3. Your custom condition: just call `GracefulCluster.gracefullyRestartCurrentWorker()` to restart current worker in `serverFunction`.\n  4. On `SIGUSR2` signal to cluster process.\n\nExample 'cluster.js':\n\n```js\nvar GracefulCluster = require('graceful-cluster').GracefulCluster;\n\nprocess.title = '<your-cluster-title>';     // Note, process title must be near filename (cluster.js) length, longer title truncated.\n\nGracefulCluster.start({\n    shutdownTimeout: 10 * 1000,             // 10 sec.\n    restartOnTimeout: 5 * 3600 * 1000,      // 5 hours.\n    restartOnMemory: 150 * 1024 * 1024,     // 150 MB.\n    serverFunction: function() {\n        require('./server');                // Your 'server.js' code module with server logic.\n    }\n});\n```\n\nGracefulCluster options description:\n\n| option                   | info\n| ------------------------ | ---\n| `disableGraceful`        | disable graceful shutdown for faster debug.\n| `exitFunction`           | optional, function that is called when the master needs to exit. The default function exits with exit code 0.\n| `log`                    | function, custom log function, `console.log` used by default.\n| `restartOnMemory`        | bytes, optional. restart worker on memory usage.\n| `restartOnTimeout`       | ms, optional. restart worker by timer.\n| `serverFunction`         | **required**, function with worker logic.\n| `shutdownTimeout`        | ms, optional. force worker shutdown on `SIGTERM` timeout. Defaults to 5000ms.\n| `workersCount`           | workers count, if not specified `os.cpus().length` will be used.\n\n### Gracefully restart cluster\n\nGraceful restart performed by `USR2` signal:\n\n```sh\npkill -USR2 <your-cluster-title>\n```\n\nor\n\n```sh\nkill -s SIGUSR2 <cluster-pid>\n```\n    \nThis method is also good if your app is launched with [forever](https://github.com/foreverjs/forever):\n\n```sh\nforever start cluster.js\n```\n\n### Using with PM2\n\nIf you prefer [PM2](https://github.com/Unitech/pm2) you should use 'server.js' patch only. This will force PM2 to wait until active connections are closed when using:\n\n```sh\npm2 reload <id>\n```\n\nWith PM2 graceful reload don`t forget to set important process parameters:\n\n - `\"instances\": 0`         - use cluster with multiple instances, so one instance will still work when another is reloaded.\n - `\"kill_timeout\": 5000`   - wait more time to allow active connections finish their responses.","maintainers":[{"name":"itteco","email":"ivan@itteco.com"}],"time":{"modified":"2022-06-18T13:45:30.221Z","created":"2016-07-26T10:23:21.984Z","0.0.1":"2016-07-26T10:23:21.984Z","0.0.2":"2017-01-11T15:00:05.042Z","0.0.3":"2017-06-08T19:36:34.874Z","0.0.4":"2017-07-13T19:49:51.100Z","0.0.5":"2017-07-14T10:58:23.304Z"},"homepage":"https://github.com/itteco/graceful-cluster#readme","keywords":["http","server","cluster","restart","shutdown","gracefully"],"repository":{"type":"git","url":"git+https://github.com/itteco/graceful-cluster.git"},"bugs":{"url":"https://github.com/itteco/graceful-cluster/issues"},"license":"MIT","readmeFilename":"README.md"}