jmcnevin-delayed_job 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,36 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
- begin
3
- require 'jeweler'
4
- rescue LoadError
5
- puts "Jeweler not available. Install it with: sudo gem install jeweler"
6
- exit 1
7
- end
8
-
9
- Jeweler::Tasks.new do |s|
10
- s.name = "delayed_job"
11
- s.summary = "Database-backed asynchronous priority queue system -- Extracted from Shopify"
12
- s.email = "tobi@leetsoft.com"
13
- s.homepage = "http://github.com/collectiveidea/delayed_job"
14
- s.description = "Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks.\n\nThis gem is collectiveidea's fork (http://github.com/collectiveidea/delayed_job)."
15
- s.authors = ["Brandon Keepers", "Tobias Lütke"]
16
-
17
- s.has_rdoc = true
18
- s.rdoc_options = ["--main", "README.textile", "--inline-source", "--line-numbers"]
19
- s.extra_rdoc_files = ["README.textile"]
20
-
21
- s.test_files = Dir['spec/*_spec.rb']
22
-
23
- s.add_development_dependency "rspec"
24
- s.add_development_dependency "sqlite3-ruby"
25
- s.add_development_dependency "mongo_mapper"
26
- s.add_development_dependency "dm-core"
27
- s.add_development_dependency "dm-observer"
28
- s.add_development_dependency "dm-aggregates"
29
- s.add_development_dependency "dm-validations"
30
- s.add_development_dependency "do_sqlite3"
31
- s.add_development_dependency "database_cleaner"
32
- end
33
-
34
2
  require 'spec/rake/spectask'
35
3
 
36
4
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.3
1
+ 2.0.6
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{jmcnevin-delayed_job}
5
- s.version = "2.0.5"
5
+ s.version = "2.0.6"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Brandon Keepers", "Tobias L\303\274tke", "Jeremy McNevin"]
9
- s.date = %q{2010-08-26}
9
+ s.date = %q{2010-08-27}
10
10
  s.description = %q{Delayed_job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. It is a direct extraction from Shopify where the job table is responsible for a multitude of core tasks.
11
11
 
12
12
  This gem is jmcnevin's fork (http://github.com/jmcnevin/delayed_job).}
@@ -21,8 +21,6 @@ This gem is jmcnevin's fork (http://github.com/jmcnevin/delayed_job).}
21
21
  "Rakefile",
22
22
  "VERSION",
23
23
  "benchmarks.rb",
24
- "contrib/delayed_job.monitrc",
25
- "contrib/delayed_job_multiple.monitrc",
26
24
  "delayed_job.gemspec",
27
25
  "generators/delayed_job/delayed_job_generator.rb",
28
26
  "generators/delayed_job/templates/migration.rb",
@@ -34,7 +32,6 @@ This gem is jmcnevin's fork (http://github.com/jmcnevin/delayed_job).}
34
32
  "lib/delayed/message_sending.rb",
35
33
  "lib/delayed/performable_method.rb",
36
34
  "lib/delayed/railtie.rb",
37
- "lib/delayed/recipes.rb",
38
35
  "lib/delayed/tasks.rb",
39
36
  "lib/delayed/worker.rb",
40
37
  "lib/delayed_job.rb",
@@ -10,20 +10,17 @@ module Delayed
10
10
  :default_priority,
11
11
  :sleep_delay,
12
12
  :logger,
13
- :trap_signals,
14
13
  :destroy_failed_jobs
14
+ cattr_reader :backend
15
15
 
16
- cattr_reader :backend
17
-
18
- # name_prefix is ignored if name is set directly
19
- attr_accessor :name_prefix
16
+ attr_accessor :name_prefix # name_prefix is ignored if name is set directly
17
+ attr_writer :name
20
18
 
21
19
  # default worker settings
22
20
  self.sleep_delay = 5
23
21
  self.max_attempts = 25
24
22
  self.max_run_time = 4.hours
25
23
  self.default_priority = 0
26
- self.trap_signals = true
27
24
  self.destroy_failed_jobs = true
28
25
 
29
26
  self.logger = if defined?(Merb::Logger)
@@ -68,23 +65,16 @@ module Delayed
68
65
  # safely resume working on tasks which are locked by themselves. The worker will assume that
69
66
  # it crashed before.
70
67
  def name
71
- return @name unless @name.nil?
72
- "#{@name_prefix}host:#{Socket.gethostname} pid:#{Process.pid}" rescue "#{@name_prefix}pid:#{Process.pid}"
73
- end
74
-
75
- # Sets the name of the worker.
76
- # Setting the name to nil will reset the default worker name
77
- def name=(val)
78
- @name = val
68
+ @name || "#{@name_prefix}host:#{Socket.gethostname} pid:#{Process.pid}"
69
+ rescue
70
+ "#{@name_prefix}pid:#{Process.pid}"
79
71
  end
80
72
 
81
73
  def start
82
74
  say "*** Starting job worker #{name}"
83
75
 
84
- if self.trap_signals
85
- trap('TERM') { say 'Exiting...'; $exit = true }
86
- trap('INT') { say 'Exiting...'; $exit = true }
87
- end
76
+ trap('TERM') { say 'Exiting...'; $exit = true }
77
+ trap('INT') { say 'Exiting...'; $exit = true }
88
78
 
89
79
  loop do
90
80
  result = nil
@@ -138,8 +128,7 @@ module Delayed
138
128
  # TODO: warn if runtime > max_run_time ?
139
129
  say "* [JOB] #{name} completed after %.4f" % runtime
140
130
  return true # did work
141
- # rescue Exception => e # rescuing Exception can have some strange downsides in my experience
142
- rescue => e
131
+ rescue Exception => e
143
132
  handle_failed_job(job, e)
144
133
  return false # work failed
145
134
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jmcnevin-delayed_job
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 5
10
- version: 2.0.5
9
+ - 6
10
+ version: 2.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Brandon Keepers
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-08-26 00:00:00 -07:00
20
+ date: 2010-08-27 00:00:00 -07:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -164,8 +164,6 @@ files:
164
164
  - Rakefile
165
165
  - VERSION
166
166
  - benchmarks.rb
167
- - contrib/delayed_job.monitrc
168
- - contrib/delayed_job_multiple.monitrc
169
167
  - delayed_job.gemspec
170
168
  - generators/delayed_job/delayed_job_generator.rb
171
169
  - generators/delayed_job/templates/migration.rb
@@ -177,7 +175,6 @@ files:
177
175
  - lib/delayed/message_sending.rb
178
176
  - lib/delayed/performable_method.rb
179
177
  - lib/delayed/railtie.rb
180
- - lib/delayed/recipes.rb
181
178
  - lib/delayed/tasks.rb
182
179
  - lib/delayed/worker.rb
183
180
  - lib/delayed_job.rb
@@ -1,14 +0,0 @@
1
- # an example Monit configuration file for delayed_job
2
- # See: http://stackoverflow.com/questions/1226302/how-to-monitor-delayedjob-with-monit/1285611
3
- #
4
- # To use:
5
- # 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc
6
- # 2. replace {app_name} as appropriate
7
- # 3. add this to your /etc/monit/monitrc
8
- #
9
- # include /var/www/apps/{app_name}/shared/delayed_job.monitrc
10
-
11
- check process delayed_job
12
- with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.pid
13
- start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start"
14
- stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop"
@@ -1,23 +0,0 @@
1
- # an example Monit configuration file for delayed_job running multiple processes
2
- #
3
- # To use:
4
- # 1. copy to /var/www/apps/{app_name}/shared/delayed_job.monitrc
5
- # 2. replace {app_name} as appropriate
6
- # 3. add this to your /etc/monit/monitrc
7
- #
8
- # include /var/www/apps/{app_name}/shared/delayed_job.monitrc
9
-
10
- check process delayed_job_0
11
- with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.0.pid
12
- start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 0"
13
- stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 0"
14
-
15
- check process delayed_job_1
16
- with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.1.pid
17
- start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 1"
18
- stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 1"
19
-
20
- check process delayed_job_2
21
- with pidfile /var/www/apps/{app_name}/shared/pids/delayed_job.2.pid
22
- start program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job start -i 2"
23
- stop program = "/usr/bin/env RAILS_ENV=production /var/www/apps/{app_name}/current/script/delayed_job stop -i 2"
@@ -1,31 +0,0 @@
1
- # Capistrano Recipes for managing delayed_job
2
- #
3
- # Add these callbacks to have the delayed_job process restart when the server
4
- # is restarted:
5
- #
6
- # after "deploy:stop", "delayed_job:stop"
7
- # after "deploy:start", "delayed_job:start"
8
- # after "deploy:restart", "delayed_job:restart"
9
-
10
- Capistrano::Configuration.instance.load do
11
- namespace :delayed_job do
12
- def rails_env
13
- fetch(:rails_env, false) ? "RAILS_ENV=#{fetch(:rails_env)}" : ''
14
- end
15
-
16
- desc "Stop the delayed_job process"
17
- task :stop, :roles => :app do
18
- run "cd #{current_path};#{rails_env} script/delayed_job stop"
19
- end
20
-
21
- desc "Start the delayed_job process"
22
- task :start, :roles => :app do
23
- run "cd #{current_path};#{rails_env} script/delayed_job start"
24
- end
25
-
26
- desc "Restart the delayed_job process"
27
- task :restart, :roles => :app do
28
- run "cd #{current_path};#{rails_env} script/delayed_job restart"
29
- end
30
- end
31
- end