raemon 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README CHANGED
@@ -3,11 +3,16 @@ Raemon
3
3
 
4
4
  Raemon is a Ruby framework for building daemons. It's designed for writing
5
5
  master/worker pre-forking servers running on UNIX. The library has been
6
- tested on both 1.8.7 and 1.9.1 and carries no dependencies outside of the
6
+ tested on both 1.8.7 and 1.9.2 and carries no dependencies outside of the
7
7
  Ruby core. More to come.
8
8
 
9
9
  By: Peter Kieltyka
10
- Copyright (c) 2007-2009 NuLayer Inc. All rights reserved.
10
+ Copyright (c) 2007-2010 NuLayer Inc. All rights reserved.
11
+
12
+ Acknowledgements:
13
+ Lots of code/ideas borrowed from the Unicorn project by Eric Wong to implement
14
+ signals, workers, and the heartbeat.
15
+
11
16
 
12
17
 
13
18
  Usage
@@ -49,7 +54,7 @@ Via gemcutter:
49
54
  $ gem install raemon
50
55
 
51
56
  From source:
52
- $ git clone git://github.com/pkieltyka/raemon.git
57
+ $ git clone git://github.com/nulayer/raemon.git
53
58
  $ cd raemon && rake build
54
59
  $ gem install pkg/raemon-X.X.X.gem
55
60
 
@@ -68,6 +73,7 @@ Thanks
68
73
  ======
69
74
  Raemon was influenced by the following projects:
70
75
 
76
+ unicorn - http://github.com/defunkt/unicorn
71
77
  servolux - http://github.com/TwP/servolux
72
78
  daemon_kit - http://github.com/kennethkalmer/daemon-kit
73
79
  rails - http://github.com/rails/rails
@@ -3,7 +3,7 @@ require 'tmpdir'
3
3
  require 'logger'
4
4
 
5
5
  module Raemon
6
- VERSION = '0.2.1'
6
+ VERSION = '0.2.2'
7
7
 
8
8
  autoload :Master, 'raemon/master'
9
9
  autoload :Worker, 'raemon/worker'
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 2
8
- - 1
9
- version: 0.2.1
8
+ - 2
9
+ version: 0.2.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Peter Kieltyka
@@ -14,58 +14,37 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-15 00:00:00 -04:00
17
+ date: 2010-07-23 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
21
- description: Raemon is a Ruby framework for building UNIX daemons.
22
- email: peter.kieltyka@nulayer.com
21
+ description: Raemon is a Ruby framework for building UNIX daemons
22
+ email:
23
+ - peter.kieltyka@nulayer.com
23
24
  executables: []
24
25
 
25
26
  extensions: []
26
27
 
27
- extra_rdoc_files:
28
- - LICENSE
29
- - README
28
+ extra_rdoc_files: []
29
+
30
30
  files:
31
- - .gitignore
32
- - LICENSE
33
31
  - README
34
- - Rakefile
35
- - VERSION
36
- - examples/beanstalk.rb
37
- - examples/evented.rb
38
- - examples/queue.rb
39
- - examples/sampled/bin/sampled
40
- - examples/sampled/config/boot.rb
41
- - examples/sampled/config/environment.rb
42
- - examples/sampled/config/environments/development.rb
43
- - examples/sampled/config/environments/production.rb
44
- - examples/sampled/config/environments/test.rb
45
- - examples/sampled/config/initializers/settings.rb
46
- - examples/sampled/config/settings.yml
47
- - examples/sampled/lib/sampled.rb
48
- - examples/sampled/log/.keep
49
- - examples/sampled/test/.keep
50
- - examples/sampled/tmp/pids/.keep
51
- - examples/sampled/vendor/.keep
52
- - examples/test.rb
53
- - lib/raemon.rb
54
32
  - lib/raemon/master.rb
55
33
  - lib/raemon/server.rb
56
34
  - lib/raemon/util.rb
57
35
  - lib/raemon/worker.rb
58
- - raemon.gemspec
36
+ - lib/raemon.rb
59
37
  has_rdoc: true
60
- homepage: http://github.com/pkieltyka/raemon
38
+ homepage: http://github.com/nulayer/raemon
61
39
  licenses: []
62
40
 
63
41
  post_install_message:
64
- rdoc_options:
65
- - --charset=UTF-8
42
+ rdoc_options: []
43
+
66
44
  require_paths:
67
45
  - lib
68
46
  required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
69
48
  requirements:
70
49
  - - ">="
71
50
  - !ruby/object:Gem::Version
@@ -73,28 +52,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
73
52
  - 0
74
53
  version: "0"
75
54
  required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
76
56
  requirements:
77
57
  - - ">="
78
58
  - !ruby/object:Gem::Version
79
59
  segments:
80
- - 0
81
- version: "0"
60
+ - 1
61
+ - 3
62
+ - 6
63
+ version: 1.3.6
82
64
  requirements: []
83
65
 
84
66
  rubyforge_project:
85
- rubygems_version: 1.3.6
67
+ rubygems_version: 1.3.7
86
68
  signing_key:
87
69
  specification_version: 3
88
- summary: Raemon is a Ruby framework for building UNIX daemons.
89
- test_files:
90
- - examples/beanstalk.rb
91
- - examples/evented.rb
92
- - examples/queue.rb
93
- - examples/sampled/config/boot.rb
94
- - examples/sampled/config/environment.rb
95
- - examples/sampled/config/environments/development.rb
96
- - examples/sampled/config/environments/production.rb
97
- - examples/sampled/config/environments/test.rb
98
- - examples/sampled/config/initializers/settings.rb
99
- - examples/sampled/lib/sampled.rb
100
- - examples/test.rb
70
+ summary: Raemon is a Ruby framework for building UNIX daemons
71
+ test_files: []
72
+
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- .DS_Store
2
- pkg
3
- *.gemspec
data/LICENSE DELETED
@@ -1,20 +0,0 @@
1
- Copyright (c) 2007-2009 NuLayer Inc. All rights reserved.
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile DELETED
@@ -1,17 +0,0 @@
1
- require 'rubygems'
2
- require 'rake'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "raemon"
8
- gem.summary = "Raemon is a Ruby framework for building UNIX daemons."
9
- gem.description = "Raemon is a Ruby framework for building UNIX daemons."
10
- gem.email = "peter.kieltyka@nulayer.com"
11
- gem.homepage = "http://github.com/pkieltyka/raemon"
12
- gem.authors = ["Peter Kieltyka"]
13
- end
14
- Jeweler::GemcutterTasks.new
15
- rescue LoadError
16
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
17
- end
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.1
@@ -1,49 +0,0 @@
1
- $:.unshift ::File.dirname(__FILE__) + '/../lib'
2
-
3
- require 'rubygems'
4
- require 'raemon'
5
- require 'beanstalk-client'
6
-
7
- class JobWorker
8
- include Raemon::Worker
9
-
10
- def start
11
- logger.info "=> Starting worker #{Process.pid}"
12
-
13
- @beanstalk = Beanstalk::Pool.new(['localhost:11300'])
14
- end
15
-
16
- def stop
17
- logger.info "=> Stopping worker #{Process.pid}"
18
-
19
- @beanstalk.close
20
- end
21
-
22
- def run
23
- loop do
24
- begin
25
- job = @beanstalk.reserve(2)
26
- rescue Beanstalk::TimedOut
27
- end
28
-
29
- if job
30
- logger.info "(#{Process.ppid}:#{Process.pid}) got job: #{job.inspect}"
31
-
32
- # process job here ...
33
- job.delete
34
- end
35
-
36
- heartbeat!
37
- end
38
- end
39
- end
40
-
41
- ROOT_DIR = File.expand_path('~')
42
-
43
- # Raemon::Master.start 3, JobWorker, {
44
- # :detach => true,
45
- # :logger => Logger.new("#{ROOT_DIR}/beanstalk.log"),
46
- # :pid_file => "#{ROOT_DIR}/beanstalk.pid"
47
- # }
48
-
49
- Raemon::Master.start 3, JobWorker
@@ -1,48 +0,0 @@
1
- $:.unshift ::File.dirname(__FILE__) + '/../lib'
2
-
3
- require 'rubygems'
4
- require 'raemon'
5
- require 'em-jack'
6
-
7
- class EventedJobWorker
8
- include Raemon::Worker
9
-
10
- def start
11
- logger.info "=> Starting worker #{Process.pid}"
12
- end
13
-
14
- def stop
15
- logger.info "=> Stopping worker #{Process.pid}"
16
-
17
- EM.stop_event_loop if EM.reactor_running?
18
- end
19
-
20
- def run
21
- EM.run do
22
- @queue = EMJack::Connection.new
23
-
24
- @queue.each_job(5) do |job|
25
- logger.info "(#{Process.ppid}:#{Process.pid}) got job: #{job.inspect}"
26
- # process(job)
27
- @queue.delete(job)
28
-
29
- heartbeat!
30
- end
31
-
32
- @queue.on_error do |error|
33
- case error
34
- when :timed_out
35
- # We use the reserve timeout for the heartbeat
36
- heartbeat!
37
-
38
- # Note: this will only run once.. we need to call the @queue.each_job
39
- # again .. maybe put it in a block
40
- else
41
- logger.error error.to_s
42
- end
43
- end
44
- end
45
- end
46
- end
47
-
48
- Raemon::Master.start 2, EventedJobWorker
@@ -1,14 +0,0 @@
1
- # Use the code below to put some jobs onto the queue to test beanstalk.rb
2
- # and evented.rb examples
3
-
4
- require 'rubygems'
5
- require 'beanstalk-client'
6
-
7
- @queue = Beanstalk::Pool.new(['localhost:11300'])
8
-
9
- num_jobs = 20
10
-
11
- (0...num_jobs).each do |id|
12
- job = "Job#{id}"
13
- @queue.put job
14
- end
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Setup environment
4
- case ARGV.first
5
- when nil
6
- ENV['RAEMON_ENV'] = 'development'
7
- when 'start'
8
- ENV['RAEMON_ENV'] = 'production'
9
- when 'stop'
10
- @shutdown = true
11
- end
12
-
13
- # Load Raemon Server
14
- require File.dirname(__FILE__) + '/../config/environment'
15
-
16
- if @shutdown
17
- Raemon::Server.shutdown!
18
- else
19
- Raemon::Server.startup!
20
- end
@@ -1,30 +0,0 @@
1
- # Don't change this file!
2
- # Configure your daemon in config/environment.rb
3
-
4
- RAEMON_ROOT = File.expand_path(File.dirname(__FILE__)+'/..') unless defined?(RAEMON_ROOT)
5
-
6
- module Raemon
7
- class << self
8
- def boot!
9
- return if defined? Raemon::Server
10
-
11
- load_vendor_libs
12
-
13
- require 'rubygems'
14
- require 'raemon'
15
-
16
- Raemon::Server.run
17
- end
18
-
19
- def load_vendor_libs
20
- Dir.entries("#{RAEMON_ROOT}/vendor").each do |vendor|
21
- vendor_lib = "#{RAEMON_ROOT}/vendor/#{vendor}/lib"
22
- if File.directory?(vendor_lib) && vendor != '..'
23
- $LOAD_PATH.unshift vendor_lib
24
- end
25
- end
26
- end
27
- end
28
- end
29
-
30
- Raemon.boot!
@@ -1,16 +0,0 @@
1
- # Be sure to restart your daemon when you modify this file
2
-
3
- # Uncomment below to force your daemon into production mode
4
- #ENV['RAEMON_ENV'] ||= 'production'
5
-
6
- require File.join(File.dirname(__FILE__), 'boot')
7
-
8
- Raemon::Server.run do |config|
9
- config.name = 'Sampled'
10
- config.worker_klass = 'Sampled::Worker'
11
- config.num_workers = 1
12
- config.timeout = 60
13
- config.memory_limit = 50 # in MB
14
-
15
- config.log_level = :info
16
- end
@@ -1,5 +0,0 @@
1
- config.detach = false
2
- config.num_workers = 2
3
- config.log_level = :debug
4
-
5
- require 'ruby-debug'
@@ -1,3 +0,0 @@
1
- config.detach = true
2
- config.num_workers = 2
3
- config.log_level = :warn
@@ -1,3 +0,0 @@
1
- config.detach = false
2
- config.num_workers = 1
3
- config.log_level = :debug
@@ -1,2 +0,0 @@
1
- require 'yaml'
2
- SETTINGS = YAML.load(File.read(RAEMON_ROOT + "/config/settings.yml"))[RAEMON_ENV]
@@ -1,8 +0,0 @@
1
- development:
2
- peter: true
3
-
4
- production:
5
- peter: false
6
-
7
- test:
8
- peter: true
@@ -1,22 +0,0 @@
1
- module Sampled
2
-
3
- class Worker
4
- include Raemon::Worker
5
-
6
- def start
7
- logger.info "=> Starting worker #{Process.pid}"
8
- end
9
-
10
- def stop
11
- logger.info "=> Stopping worker #{Process.pid}"
12
- end
13
-
14
- def run
15
- loop do
16
- logger.warn "I'm executing .. #{Process.ppid}:#{Process.pid}"
17
- sleep 2
18
- end
19
- end
20
- end
21
-
22
- end
File without changes
File without changes
File without changes
File without changes
@@ -1,36 +0,0 @@
1
- $:.unshift ::File.dirname(__FILE__) + '/../lib'
2
-
3
- require 'rubygems'
4
- require 'raemon'
5
-
6
- class Test
7
- include Raemon::Worker
8
-
9
- def start
10
- logger.info "=> Starting worker #{Process.pid}"
11
- end
12
-
13
- def stop
14
- logger.info "=> Stopping worker #{Process.pid}"
15
- end
16
-
17
- def run
18
- x = 0
19
-
20
- loop do
21
- logger.warn "I'm executing #{x}.. #{Process.ppid}:#{Process.pid}"
22
-
23
- if x < 3
24
- sleep 2
25
- else
26
- sleep 6
27
- end
28
-
29
- heartbeat!
30
-
31
- x += 1
32
- end
33
- end
34
- end
35
-
36
- Raemon::Master.start 2, Test, :timeout => 5