{"id":20085411,"url":"https://github.com/klaxit/sidekiq-worker-killer","last_synced_at":"2025-04-13T00:43:28.164Z","repository":{"id":47048208,"uuid":"129921822","full_name":"klaxit/sidekiq-worker-killer","owner":"klaxit","description":"🔪 Kill glutton Sidekiq processes","archived":false,"fork":false,"pushed_at":"2024-01-17T20:16:49.000Z","size":54,"stargazers_count":165,"open_issues_count":1,"forks_count":29,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-13T00:43:02.678Z","etag":null,"topics":["ruby","ruby-on-rails","sidekiq"],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/klaxit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-04-17T15:00:56.000Z","updated_at":"2025-03-07T09:51:25.000Z","dependencies_parsed_at":"2024-06-19T09:54:24.333Z","dependency_job_id":"1b7df5d8-70a3-4d2f-877e-55694a9cfd18","html_url":"https://github.com/klaxit/sidekiq-worker-killer","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaxit%2Fsidekiq-worker-killer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaxit%2Fsidekiq-worker-killer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaxit%2Fsidekiq-worker-killer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/klaxit%2Fsidekiq-worker-killer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/klaxit","download_url":"https://codeload.github.com/klaxit/sidekiq-worker-killer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248650418,"owners_count":21139672,"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":["ruby","ruby-on-rails","sidekiq"],"created_at":"2024-11-13T15:55:51.530Z","updated_at":"2025-04-13T00:43:28.135Z","avatar_url":"https://github.com/klaxit.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# sidekiq-worker-killer\n[![Gem Version](https://badge.fury.io/rb/sidekiq-worker-killer.svg)](https://badge.fury.io/rb/sidekiq-worker-killer)\n[![CircleCI](https://circleci.com/gh/klaxit/sidekiq-worker-killer.svg?style=shield\u0026circle-token=:circle-token)](https://circleci.com/gh/klaxit/sidekiq-worker-killer)\n\n[Sidekiq](https://github.com/mperham/sidekiq) is probably the best background processing framework today. At the same time, memory leaks are very hard to tackle in Ruby and we often find ourselves with growing memory consumption. Instead of spending herculean effort fixing leaks, why not kill your processes when they got to be too large?\n\nHighly inspired by [Gitlab Sidekiq MemoryKiller](https://gitlab.com/gitlab-org/gitlab-foss/-/blob/39c1731a53d1014eab7c876d70632b1abf738712/lib/gitlab/sidekiq_middleware/shutdown.rb) and [Noxa Sidekiq killer](https://github.com/Noxa/sidekiq-killer).\n\n---\n**NOTE**\n\nThis gem needs to get the used memory of the Sidekiq process. For\nthis we use [GetProcessGem](https://github.com/schneems/get_process_mem),\nbut be aware that if you are running Sidekiq in Heroku(or any container) the\nmemory usage will\n[not be accurate](https://github.com/schneems/get_process_mem/issues/7).\n\n---\n\nquick-refs: [install](#install) | [usage](#usage) | [available options](#available-options) | [development](#development)\n\n## Install\nUse [Bundler](http://bundler.io/)\n```ruby\ngem \"sidekiq-worker-killer\"\n```\n\n## Usage\n\nAdd this to your Sidekiq configuration.\n\n```ruby\nrequire 'sidekiq/worker_killer'\n\nSidekiq.configure_server do |config|\n  config.server_middleware do |chain|\n    chain.add Sidekiq::WorkerKiller, max_rss: 480\n  end\nend\n```\n\n## Available options\n\nThe following options can be overridden.\n\n| Option | Defaults | Description |\n| ------- | ------- | ----------- |\n| max_rss | 0 MB (disabled) | Max RSS in megabytes used by the Sidekiq process. Above this, shutdown will be triggered. |\n| grace_time | 900 seconds | When shutdown is triggered, the Sidekiq process will not accept new job and wait at most 15 minutes for running jobs to finish. If Float::INFINITY specified, will wait forever. |\n| shutdown_wait | 30 seconds | When the grace time expires, still running jobs get 30 seconds to stop. After that, kill signal is triggered. |\n| kill_signal | SIGKILL | Signal to use to kill Sidekiq process if it doesn't stop. |\n| gc | true | Try to run garbage collection before Sidekiq process stops in case of exceeded max_rss. |\n| skip_shutdown_if | proc {false} | Executes a block of code after max_rss exceeds but before requesting shutdown. |\n| on_shutdown | nil | Executes a block of code before just before requesting shutdown. This can be used to send custom logs or metrics to external services. |\n\n*skip_shutdown_if* is expected to return anything other than `false` or `nil` to skip shutdown.\n\n```ruby\nrequire 'sidekiq/worker_killer'\n\nSidekiq.configure_server do |config|\n  config.server_middleware do |chain|\n    chain.add Sidekiq::WorkerKiller, max_rss: 480, skip_shutdown_if: -\u003e(worker, job, queue) do\n      worker.to_s == 'LongWorker'\n    end\n  end\nend\n```\n\n## Development\n\nPull Requests are very welcome!\n\nThere are tasks that may help you along the way in a makefile:\n\n```bash\nmake console # Loads the whole stack in an IRB session.\nmake test # Run tests.\nmake lint # Run rubocop linter.\n```\nPlease make sure that you have tested your code carefully before opening a PR, and make sure as well that you have no style issues.\n\n## Authors\n\nSee the list of [contributors](https://github.com/klaxit/sidekiq-worker-killer/contributors) who participated in this project.\n\n## License\n\nPlease see [LICENSE](https://github.com/klaxit/sidekiq-worker-killer/blob/master/LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklaxit%2Fsidekiq-worker-killer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fklaxit%2Fsidekiq-worker-killer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fklaxit%2Fsidekiq-worker-killer/lists"}