hireling 0.1.5 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/hirelings_ctl +1 -3
- data/lib/hireling.rb +4 -1
- data/lib/hireling/hireling.rb +9 -6
- data/lib/hireling/hirelings.rb +9 -3
- metadata +3 -3
data/Rakefile
CHANGED
@@ -6,7 +6,7 @@ specification = Gem::Specification.new do |s|
|
|
6
6
|
s.platform = Gem::Platform::RUBY
|
7
7
|
s.name = "hireling"
|
8
8
|
s.summary = "Simple scheduled process structure for Rails apps."
|
9
|
-
s.version = "0.1
|
9
|
+
s.version = "0.2.1"
|
10
10
|
s.author = "David Vollbracht, Scott Conley"
|
11
11
|
s.description = s.summary
|
12
12
|
s.email = "scott.conley@flipstone.com"
|
data/bin/hirelings_ctl
CHANGED
@@ -2,8 +2,6 @@
|
|
2
2
|
require 'rubygems'
|
3
3
|
require "daemons"
|
4
4
|
|
5
|
-
options = {:dir => "log/", :monitor => false, :multiple => false, :dir_mode => :normal}
|
6
|
-
|
7
|
-
ENV["foo"] ||= Dir.pwd
|
5
|
+
options = {:dir => "log/", :monitor => false, :multiple => false, :dir_mode => :normal, :rails_root => Dir.pwd}
|
8
6
|
|
9
7
|
Daemons.run File.dirname(__FILE__) + '/../lib/hireling/hirelings.rb', options
|
data/lib/hireling.rb
CHANGED
data/lib/hireling/hireling.rb
CHANGED
@@ -5,15 +5,18 @@ class Hireling
|
|
5
5
|
attr_accessor :schedule
|
6
6
|
end
|
7
7
|
|
8
|
-
def self.each_app_hireling_name
|
9
|
-
Dir[File.join(
|
8
|
+
def self.each_app_hireling_name(rails_root)
|
9
|
+
hireling_classes ||= Dir[File.join(rails_root, %w(app hirelings *.rb))]
|
10
|
+
hireling_classes ||= Dir[File.join(%w(app hirelings *.rb))]
|
11
|
+
hireling_classes.each do |hireling_file|
|
12
|
+
require hireling_file
|
10
13
|
hireling_name = File.basename(hireling_file, '.rb')
|
11
14
|
yield hireling_name.to_sym
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
15
18
|
def self.schedule_with_scheduler(scheduler)
|
16
|
-
|
19
|
+
Hireling.schedule.schedule(scheduler, new)
|
17
20
|
info "scheduled"
|
18
21
|
end
|
19
22
|
|
@@ -39,7 +42,7 @@ class Hireling
|
|
39
42
|
end
|
40
43
|
|
41
44
|
def self.info(message)
|
42
|
-
Rails.logger.info "
|
45
|
+
Rails.logger.info "Hireling #{name} at #{Time.now}: #{message}"
|
43
46
|
end
|
44
47
|
|
45
48
|
class Schedule
|
@@ -52,8 +55,8 @@ class Hireling
|
|
52
55
|
|
53
56
|
def schedule(rufus_scheduler, hireling)
|
54
57
|
proxy = @proxies[hireling.class.name.underscore.to_sym]
|
55
|
-
raise "No schedule found for #{hireling.class}" unless proxy
|
56
|
-
proxy.replay(rufus_scheduler
|
58
|
+
raise "No schedule found for #{hireling.class.name.underscore.to_sym}" unless proxy
|
59
|
+
proxy.replay(rufus_scheduler,hireling)
|
57
60
|
end
|
58
61
|
end
|
59
62
|
|
data/lib/hireling/hirelings.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
#
|
3
|
+
# This file is invoked by the Daemons.run and launches the hirelings.
|
4
|
+
# Hireling control relies on the Rails environment for:
|
5
|
+
# - config/initializers/hirelings_schedule.rb
|
6
|
+
# - app/hirelings/<your_hirelings>.rb
|
7
|
+
#
|
3
8
|
ENV["RAILS_ENV"] ||= "development"
|
4
9
|
|
5
|
-
require "
|
10
|
+
require "daemons"
|
6
11
|
require 'rufus/scheduler'
|
12
|
+
require "#{Daemons.controller.options[:rails_root]}/config/environment"
|
7
13
|
|
8
14
|
scheduler = Rufus::Scheduler.start_new
|
9
15
|
|
10
|
-
Hireling.each_app_hireling_name do |hireling_name|
|
11
|
-
hireling_class = hireling_name.to_s.
|
16
|
+
Hireling.each_app_hireling_name(Daemons.controller.options[:rails_root]) do |hireling_name|
|
17
|
+
hireling_class = hireling_name.to_s.camelize.constantize
|
12
18
|
hireling_class.schedule_with_scheduler scheduler
|
13
19
|
end
|
14
20
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hireling
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 2
|
8
9
|
- 1
|
9
|
-
|
10
|
-
version: 0.1.5
|
10
|
+
version: 0.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- David Vollbracht, Scott Conley
|