{"id":21062415,"url":"https://github.com/rnd-soft/main_loop","last_synced_at":"2025-09-14T08:32:52.383Z","repository":{"id":56882618,"uuid":"211314479","full_name":"RND-SOFT/main_loop","owner":"RND-SOFT","description":"[MIRROR] Main Loop implementation to control subprocesses and threads","archived":false,"fork":false,"pushed_at":"2023-04-03T15:02:05.000Z","size":22,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-12-29T22:29:28.440Z","etag":null,"topics":["gem","loop","mainloop","ruby","ruby-on-rails"],"latest_commit_sha":null,"homepage":"https://br.rnds.pro/ruby/main_loop","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/RND-SOFT.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-27T12:28:53.000Z","updated_at":"2023-04-03T14:54:47.000Z","dependencies_parsed_at":"2024-11-15T05:38:00.870Z","dependency_job_id":null,"html_url":"https://github.com/RND-SOFT/main_loop","commit_stats":{"total_commits":11,"total_committers":1,"mean_commits":11.0,"dds":0.0,"last_synced_commit":"40f8de3ca050d1dadf41a316138346608ca5a8b8"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fmain_loop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fmain_loop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fmain_loop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RND-SOFT%2Fmain_loop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RND-SOFT","download_url":"https://codeload.github.com/RND-SOFT/main_loop/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232962556,"owners_count":18603378,"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":["gem","loop","mainloop","ruby","ruby-on-rails"],"created_at":"2024-11-19T17:38:50.115Z","updated_at":"2025-01-08T01:51:51.324Z","avatar_url":"https://github.com/RND-SOFT.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MainLoop\n\n[![Gem Version](https://badge.fury.io/rb/main_loop.svg)](https://rubygems.org/gems/main_loop)\n[![Gem](https://img.shields.io/gem/dt/main_loop.svg)](https://rubygems.org/gems/main_loop/versions)\n[![YARD](https://badgen.net/badge/YARD/doc/blue)](http://www.rubydoc.info/gems/main_loop)\n\n[![Test Coverage](https://api.codeclimate.com/v1/badges/baf9b1dc3dae87f7edfd/test_coverage)](https://codeclimate.com/github/RnD-Soft/main_loop/test_coverage)\n[![Maintainability](https://api.codeclimate.com/v1/badges/baf9b1dc3dae87f7edfd/maintainability)](https://codeclimate.com/github/RnD-Soft/main_loop/maintainability)\n[![Quality](https://lysander.rnds.pro/api/v1/badges/main_loop_quality.svg)](https://lysander.x.rnds.pro/api/v1/badges/main_loop_quality.html)\n[![Outdated](https://lysander.rnds.pro/api/v1/badges/main_loop_outdated.svg)](https://lysander.x.rnds.pro/api/v1/badges/main_loop_outdated.html)\n[![Vulnerabilities](https://lysander.rnds.pro/api/v1/badges/main_loop_vulnerable.svg)](https://lysander.x.rnds.pro/api/v1/badges/main_loop_vulnerable.html)\n\nMainLoop is a simple main application implementation to control subprocesses(children) and threads.\n\nFeatures:\n- reaping children\n- handling SIGTERM SIGINT to shutdown children(and threads) gracefully\n- restarting children\n- termination the children\n\n# Usage\n\nExample usage:\n\n```ruby\nrequire 'main_loop'\n\nlogger = Logger.new(STDOUT)\nlogger.level = Logger::DEBUG\n\nbus = MainLoop::Bus.new\n\ndispatcher = MainLoop::Dispatcher.new(bus, logger: logger)\nmainloop = MainLoop::Loop.new(bus, dispatcher, logger: logger)\n\nMainLoop::ProcessHandler.new dispatcher, 'test1', retry_count: 3, logger: logger do\n  sleep 2\n  exit! 0\nend\n\nMainLoop::ProcessHandler.new dispatcher, 'test2', retry_count: 2, logger: logger do\n  trap 'TERM' do\n    exit(0)\n  end\n  sleep 2\n  exit! 1\nend\n\nMainLoop::ThreadHandler.new dispatcher, 'thread2', retry_count: 0, logger: logger do\n  system('sleep 15;echo ok')\nend\n\nmainloop.run\n```\n\n\n# Installation\n\nIt's a gem:\n```bash\n  gem install main_loop\n```\nThere's also the wonders of [the Gemfile](http://bundler.io):\n```ruby\n  gem 'main_loop'\n```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnd-soft%2Fmain_loop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frnd-soft%2Fmain_loop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frnd-soft%2Fmain_loop/lists"}