Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

main_loop

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

main_loop

  • 0.1.3.16874
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

MainLoop

Gem Version Gem YARD

Test Coverage Maintainability Quality Outdated Vulnerabilities

MainLoop is a simple main application implementation to control subprocesses(children) and threads.

Features:

  • reaping children
  • handling SIGTERM SIGINT to shutdown children(and threads) gracefully
  • restarting children
  • termination the children

Usage

Example usage:

require 'main_loop'

logger = Logger.new(STDOUT)
logger.level = Logger::DEBUG

bus = MainLoop::Bus.new

dispatcher = MainLoop::Dispatcher.new(bus, logger: logger)
mainloop = MainLoop::Loop.new(bus, dispatcher, logger: logger)

MainLoop::ProcessHandler.new dispatcher, 'test1', retry_count: 3, logger: logger do
  sleep 2
  exit! 0
end

MainLoop::ProcessHandler.new dispatcher, 'test2', retry_count: 2, logger: logger do
  trap 'TERM' do
    exit(0)
  end
  sleep 2
  exit! 1
end

MainLoop::ThreadHandler.new dispatcher, 'thread2', retry_count: 0, logger: logger do
  system('sleep 15;echo ok')
end

mainloop.run

Installation

It's a gem:

  gem install main_loop

There's also the wonders of the Gemfile:

  gem 'main_loop'

FAQs

Package last updated on 30 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc