forkpool 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +4 -0
- data/Rakefile +15 -0
- data/forkpool.gemspec +30 -0
- data/lib/forkpool.rb +12 -0
- data/readme +33 -0
- metadata +77 -0
data/Manifest
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('forkpool', '0.0.4') do |p|
|
6
|
+
p.description = "Manage a fork pool"
|
7
|
+
p.url = "http://github.com/pmamediagroup/forkpool"
|
8
|
+
p.author = "Tracey Eubanks"
|
9
|
+
p.email = "traceye@pmamediagroup.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
15
|
+
|
data/forkpool.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{forkpool}
|
5
|
+
s.version = "0.0.4"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Tracey Eubanks"]
|
9
|
+
s.date = %q{2010-08-03}
|
10
|
+
s.description = %q{Manage a fork pool}
|
11
|
+
s.email = %q{traceye@pmamediagroup.com}
|
12
|
+
s.extra_rdoc_files = ["lib/forkpool.rb"]
|
13
|
+
s.files = ["Rakefile", "lib/forkpool.rb", "readme", "Manifest", "forkpool.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/pmamediagroup/forkpool}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Forkpool", "--main", "readme"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{forkpool}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{Manage a fork pool}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
data/lib/forkpool.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# a lot of code taken from tmtm's tserver v0.3.2a
|
2
|
+
# http://www.tmtm.org/ruby/tserver/
|
3
|
+
|
4
|
+
require 'socket'
|
5
|
+
require File.expand_path(File.join("forkpool", "default_logger"), File.dirname(__FILE__))
|
6
|
+
require File.expand_path(File.join("forkpool", "children"), File.dirname(__FILE__))
|
7
|
+
require File.expand_path(File.join("forkpool", "forkpool"), File.dirname(__FILE__))
|
8
|
+
require File.expand_path(File.join("forkpool", "child"), File.dirname(__FILE__))
|
9
|
+
|
10
|
+
# Dir.glob(File.expand_path(File.join("forkpool", "*"), File.dirname(__FILE__))).each do |f|
|
11
|
+
# require f
|
12
|
+
# end
|
data/readme
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
gem install forkpool
|
2
|
+
|
3
|
+
A library for managing forks
|
4
|
+
|
5
|
+
The mother process spawns a fork and opens an io from the child to the parent and vice versa.
|
6
|
+
If the mother process dies, the children commit suicide. They also accept HUP and INT calls and die then as well.
|
7
|
+
|
8
|
+
Used like so,
|
9
|
+
|
10
|
+
forkpool = Forkpool.start(num_of_childs, Logger)
|
11
|
+
forkpool.start do
|
12
|
+
sleep 10
|
13
|
+
puts "hey!!!"
|
14
|
+
end
|
15
|
+
|
16
|
+
The above code will continuously print "hey!!!". Once the child process has slept 10 seconds and printed "hey!!!" it will die and the mother process will start another to replace it.
|
17
|
+
You can start this in a thread if you'd like to have control back after spawning the children.
|
18
|
+
Thread.new do
|
19
|
+
forkpool.start do
|
20
|
+
...
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
If you have to change the number of max forks forkpool should spawn, it can be done
|
25
|
+
forkpool = Forkpool.start(num_of_childs, Logger)
|
26
|
+
forkpool.start do
|
27
|
+
forkpool.max_forks = new_num_of_childs
|
28
|
+
sleep 10
|
29
|
+
...do something...
|
30
|
+
end
|
31
|
+
|
32
|
+
Have fun and enjoy :]
|
33
|
+
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: forkpool
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 4
|
10
|
+
version: 0.0.4
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Tracey Eubanks
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-08-03 00:00:00 -06:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Manage a fork pool
|
23
|
+
email: traceye@pmamediagroup.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- lib/forkpool.rb
|
30
|
+
files:
|
31
|
+
- Rakefile
|
32
|
+
- lib/forkpool.rb
|
33
|
+
- readme
|
34
|
+
- Manifest
|
35
|
+
- forkpool.gemspec
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/pmamediagroup/forkpool
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --line-numbers
|
43
|
+
- --inline-source
|
44
|
+
- --title
|
45
|
+
- Forkpool
|
46
|
+
- --main
|
47
|
+
- readme
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 3
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 11
|
65
|
+
segments:
|
66
|
+
- 1
|
67
|
+
- 2
|
68
|
+
version: "1.2"
|
69
|
+
requirements: []
|
70
|
+
|
71
|
+
rubyforge_project: forkpool
|
72
|
+
rubygems_version: 1.3.7
|
73
|
+
signing_key:
|
74
|
+
specification_version: 3
|
75
|
+
summary: Manage a fork pool
|
76
|
+
test_files: []
|
77
|
+
|