Spool
Manage and keep alive pool of processes
Installation
Add this line to your application's Gemfile:
gem 'spool'
And then execute:
$ bundle
Or install it yourself as:
$ gem install spool
Usage
Setup
Worker
loop do
puts "#{Process.pid} - #{Time.now}"
sleep 1
end
Pool config
processes 4
command 'ruby worker.rb'
# optional
dir File.dirname(__FILE__)
env VAR1: 'foo', VAR2: 'bar'
pidfile 'pool.pid'
restart_when { |p| p.memory > 512 }
Start
console:~$ spool pool_config.rb
Signals
- INT/TERM: quick shutdown, kills all processes immediately
- QUIT: graceful shutdown, waits for processes to finish
- HUP: reloads config file and gracefully restart all processes
- USR2: gracefully restart all processes with current configuration
- TTIN: increment the number of processes by one
- TTOU: decrement the number of processes by one
Contributing
- Fork it ( https://github.com/gabynaiman/spool/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request