Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kostya/forking
Simple processes forking, and restarting. Master process starts as daemon.
https://github.com/kostya/forking
Last synced: 20 days ago
JSON representation
Simple processes forking, and restarting. Master process starts as daemon.
- Host: GitHub
- URL: https://github.com/kostya/forking
- Owner: kostya
- License: mit
- Created: 2012-06-29T23:47:38.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2012-06-30T00:13:24.000Z (over 12 years ago)
- Last Synced: 2024-10-18T11:28:10.819Z (26 days ago)
- Language: Ruby
- Homepage:
- Size: 97.7 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Forking
=======Simple processes forking, and restarting. Master process starts as daemon.
$ gem install forking
Example 1.rb (run 5 child processes and capturing logs):
```ruby
#!/usr/bin/env ruby
require 'rubygems'
require 'forking'f = Forking.new(:name => 'test', :working_dir => File.dirname(__FILE__),
:log_file => "spawner.log", :pid_file => "spawner.pid", :sync_log => true)f.before_fork do
puts "load env"
endf.after_fork do
puts "restart connects"
end2.times do |i|
f.spawn(:name => "test1", :log_file => "test1.log") do
loop do
puts "test1 #{i}"
sleep 1
end
end
end3.times do |i|
f.spawn(:log_file => "test2.log", :sync_log => true) do
exec 'ruby', '2.rb', '--test'
end
endf.run!
```Usage:
$ ./1.rb start
$ ./1.rb status
$ ./1.rb stop
$ ./1.rb restartRespawn childs:
$ kill -HUP master_pid