forkme 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. data/Manifest +4 -0
  2. data/Rakefile +18 -0
  3. data/forkme.gemspec +30 -0
  4. data/lib/forkme.rb +8 -0
  5. data/readme +33 -0
  6. metadata +65 -0
data/Manifest ADDED
@@ -0,0 +1,4 @@
1
+ Rakefile
2
+ lib/forkme.rb
3
+ readme
4
+ Manifest
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+ require 'rspec/core/rake_task'
5
+
6
+ # Echoe.new('forkme', '0.0.5') do |p|
7
+ # p.description = "Manage a fork pool"
8
+ # p.url = "http://github.com/narshlob/forkme"
9
+ # p.author = "Tracey Eubanks"
10
+ # p.email = "traceye@pmamediagroup.com"
11
+ # p.ignore_pattern = ["tmp/*", "script/*"]
12
+ # p.development_dependencies = []
13
+ # end
14
+
15
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
16
+
17
+ RSpec::Core::RakeTask.new(:spec)
18
+ task :default => :spec
data/forkme.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{forkme}
5
+ s.version = "0.0.6"
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/forkme.rb"]
13
+ s.files = ["Rakefile", "lib/forkme.rb", "readme", "Manifest", "forkme.gemspec"]
14
+ s.homepage = %q{http://github.com/narshlob/forkme}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Forkme", "--main", "readme"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{forkme}
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/forkme.rb ADDED
@@ -0,0 +1,8 @@
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("forkme", "default_logger"), File.dirname(__FILE__))
6
+ require File.expand_path(File.join("forkme", "children"), File.dirname(__FILE__))
7
+ require File.expand_path(File.join("forkme", "forkme"), File.dirname(__FILE__))
8
+ require File.expand_path(File.join("forkme", "child"), File.dirname(__FILE__))
data/readme ADDED
@@ -0,0 +1,33 @@
1
+ gem install forkme
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
+ forkme = Forkme.start(num_of_childs, Logger)
11
+ forkme.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
+ forkme.start do
20
+ ...
21
+ end
22
+ end
23
+
24
+ If you have to change the number of max forks forkme should spawn, it can be done
25
+ forkme = Forkme.start(num_of_childs, Logger)
26
+ forkme.start do
27
+ forkme.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,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: forkme
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.6
6
+ platform: ruby
7
+ authors:
8
+ - Tracey Eubanks
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2010-08-03 00:00:00 -06:00
14
+ default_executable:
15
+ dependencies: []
16
+
17
+ description: Manage a fork pool
18
+ email: traceye@pmamediagroup.com
19
+ executables: []
20
+
21
+ extensions: []
22
+
23
+ extra_rdoc_files:
24
+ - lib/forkme.rb
25
+ files:
26
+ - Rakefile
27
+ - lib/forkme.rb
28
+ - readme
29
+ - Manifest
30
+ - forkme.gemspec
31
+ has_rdoc: true
32
+ homepage: http://github.com/narshlob/forkme
33
+ licenses: []
34
+
35
+ post_install_message:
36
+ rdoc_options:
37
+ - --line-numbers
38
+ - --inline-source
39
+ - --title
40
+ - Forkme
41
+ - --main
42
+ - readme
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: "0"
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "1.2"
57
+ requirements: []
58
+
59
+ rubyforge_project: forkme
60
+ rubygems_version: 1.5.0
61
+ signing_key:
62
+ specification_version: 3
63
+ summary: Manage a fork pool
64
+ test_files: []
65
+