{"id":18510791,"url":"https://github.com/envato/forked","last_synced_at":"2025-12-27T09:46:59.733Z","repository":{"id":32875740,"uuid":"126755046","full_name":"envato/forked","owner":"envato","description":"Forked manages long running worker processes","archived":false,"fork":false,"pushed_at":"2025-10-01T03:39:52.000Z","size":41,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":58,"default_branch":"master","last_synced_at":"2025-10-18T08:58:36.758Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/envato.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2018-03-26T01:01:34.000Z","updated_at":"2025-10-01T03:39:56.000Z","dependencies_parsed_at":"2024-08-02T14:27:23.005Z","dependency_job_id":"04ce3274-5f16-43d4-a736-3fa88946aff6","html_url":"https://github.com/envato/forked","commit_stats":{"total_commits":24,"total_committers":6,"mean_commits":4.0,"dds":0.5416666666666667,"last_synced_commit":"44f2e45ca436610f1ed97c14b23c7919f0c2da1e"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/envato/forked","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fforked","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fforked/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fforked/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fforked/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/envato","download_url":"https://codeload.github.com/envato/forked/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/envato%2Fforked/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281476672,"owners_count":26508145,"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","status":"online","status_checked_at":"2025-10-28T02:00:06.022Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-06T15:25:09.810Z","updated_at":"2025-10-29T21:03:50.618Z","avatar_url":"https://github.com/envato.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Forked\n\n[![License MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](https://github.com/envato/forked/blob/master/LICENSE.txt)\n[![Gem Version](https://img.shields.io/gem/v/forked.svg?maxAge=2592000)](https://rubygems.org/gems/forked)\n[![Gem Downloads](https://img.shields.io/gem/dt/forked.svg?maxAge=2592000)](https://rubygems.org/gems/forked)\n[![Test Suite](https://github.com/envato/forked/workflows/tests/badge.svg?branch=master)](https://github.com/envato/forked/actions?query=branch%3Amaster+workflow%3Atests)\n\nForked manages long running worker processes.\n\nProcesses that crash are restarted, whereas processes that exit successfully\naren't. Errors that occur within forked processes are retried according to the\nconfigured retry strategy.\n\nOnce `wait_for_shutdown` is called, the current process watches for shutdown\nsignals or crashed processes. On shutdown, each worker is sent a TERM signal,\nindicating that it should finish any in progress work and shutdown. After a set\ntimeout period workers are sent a KILL signal.\n\n## Usage\n\n```ruby\nrequire 'forked'\n\nprocess_manager = Forked::ProcessManager.new(logger: Logger.new(STDOUT), process_timeout: 5)\n\n# Default retry_strategy = Forked::RetryStrategies::Always\n# Calling `ready_to_stop` within the loop ensures a shutdown is triggered if a TERM/INT signal is received\nprocess_manager.fork('monitor', on_error: -\u003e(e, tries) { puts e.inspect }) do |ready_to_stop|\n  loop do\n    ready_to_stop.call\n    # do something\n  end\nend\n\n# Using the ExponentialBackoff retry_strategy\n# If there is an error, process_manager backs off for a time then restarts the loop\n# The back off time increases as the number of errors increase\nprocess_manager.fork('processor_1', retry_strategy: Forked::RetryStrategies::ExponentialBackoff) do |ready_to_stop|\n  loop do\n    ready_to_stop.call\n    # do something\n  end\nend\n\n# Using the ExponentialBackoffWithLimit retry_strategy\n# Follows the ExponentialBackoff retry strategy, but if the error keeps occurring\n#   until a given limit (default: 8), the error bubbles up and the loop is not restarted\nprocess_manager.fork('processor_1', retry_strategy: Forked::RetryStrategies::ExponentialBackoffWithLimit, retry_backoff_limit: 10) do |ready_to_stop|\n  loop do\n    ready_to_stop.call\n    # do something\n  end\nend\n\n# blocks the current process, restarts any crashed processes and waits for shutdown signals (TERM/INT).\nprocess_manager.wait_for_shutdown\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/envato/forked.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvato%2Fforked","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fenvato%2Fforked","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fenvato%2Fforked/lists"}