- Notifications
You must be signed in to change notification settings - Fork0
[MIRROR] Main Loop implementation to control subprocesses and threads
License
NotificationsYou must be signed in to change notification settings
RND-SOFT/main_loop
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
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
Example usage:
require'main_loop'logger=Logger.new(STDOUT)logger.level=Logger::DEBUGbus=MainLoop::Bus.newdispatcher=MainLoop::Dispatcher.new(bus,logger:logger)mainloop=MainLoop::Loop.new(bus,dispatcher,logger:logger)MainLoop::ProcessHandler.newdispatcher,'test1',retry_count:3,logger:loggerdosleep2exit!0endMainLoop::ProcessHandler.newdispatcher,'test2',retry_count:2,logger:loggerdotrap'TERM'doexit(0)endsleep2exit!1endMainLoop::ThreadHandler.newdispatcher,'thread2',retry_count:0,logger:loggerdosystem('sleep 15;echo ok')endmainloop.run
It's a gem:
gem install main_loop
There's also the wonders ofthe Gemfile:
gem'main_loop'