{"id":22059289,"url":"https://github.com/opentable/hapi-shutdown","last_synced_at":"2025-05-12T19:44:34.546Z","repository":{"id":26740635,"uuid":"30198304","full_name":"opentable/hapi-shutdown","owner":"opentable","description":"handle SIGTERM and register triggers to be run before the server stops","archived":false,"fork":false,"pushed_at":"2020-04-22T16:42:21.000Z","size":7,"stargazers_count":8,"open_issues_count":1,"forks_count":2,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-05-02T11:16:29.325Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/opentable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-02T17:18:01.000Z","updated_at":"2019-11-14T15:13:38.000Z","dependencies_parsed_at":"2022-07-25T02:34:39.288Z","dependency_job_id":null,"html_url":"https://github.com/opentable/hapi-shutdown","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-shutdown","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-shutdown/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-shutdown/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/opentable%2Fhapi-shutdown/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/opentable","download_url":"https://codeload.github.com/opentable/hapi-shutdown/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253809775,"owners_count":21967795,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-30T17:27:52.490Z","updated_at":"2025-05-12T19:44:34.520Z","avatar_url":"https://github.com/opentable.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#Hapi-shutdown\n[![Build Status](https://travis-ci.org/opentable/hapi-shutdown.png?branch=master)](https://travis-ci.org/opentable/hapi-shutdown) [![NPM version](https://badge.fury.io/js/hapi-shutdown.png)](http://badge.fury.io/js/hapi-shutdown) ![Dependencies](https://david-dm.org/opentable/hapi-shutdown.png)\n\nPlugin listens to SIGTERM and then runs optional triggers before calling server.stop\n\nThis is for things that need to happen *before* `server.stop` is called.\n\nFor things that need to happen after server.stop, you can use `server.on('stop', ...)`\n\nUsage:\n\n```\nvar Hapi = require(\"hapi\");\nvar server = new Hapi.Server();\n\nserver.register([\n  {\n    plugin: require('hapi-shutdown'),\n    options: {\n      serverSpindownTime: 10000 // time to wait for existing connections before forcibly stopping the server\n    }\n  }],\n  function(err){\n    server.start(function(){\n\n      server.plugins['hapi-shutdown'].register({\n        taskname: 'do stuff',\n        task: function(done){ console.log('doing stuff before server.stop is called'); done(); },\n        timeout: 2000 // time to wait\n      })\n    });\n  });\n\n```\n\n__.register(_task_)__\n\nRegister a task to be run before server.stop is called. Can be called as part of another plugin, or using `server.after()`.\n\nParam: `task`\n```\n{\n  taskname: 'mytask', // used for logging and to guard against multiple registrations\n  task: function(done){\n    // do stuff\n    done()\n  },\n  timeout: 2000 // time in ms to wait for the task to complete\n}\n```\n\nReturns: a joi validation error for the task.\n\n__Logging__:\n\nWill log using 'server.log()' and the tag \"shutdown\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fhapi-shutdown","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopentable%2Fhapi-shutdown","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopentable%2Fhapi-shutdown/lists"}