pipa-monkeyjob 0.1.3 → 0.1.4

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.
@@ -71,7 +71,7 @@ module Monkey
71
71
  synchronize do
72
72
  @jobs.delete(cookie.id)
73
73
  if cookie.success?
74
- JobModel.delete(cookie.id)
74
+ Monkey.logger.hush { JobModel.delete(cookie.id) }
75
75
  Monkey.logger.debug "Deleted job #{cookie}"
76
76
  end
77
77
  end
@@ -5,10 +5,10 @@ module Monkey
5
5
  def run_local(*args)
6
6
  super(*args) do
7
7
  begin
8
- ActiveRecord::Base.dirty_reconnect!
8
+ ::ActiveRecord::Base.dirty_reconnect!
9
9
  yield(*args)
10
10
  ensure
11
- ActiveRecord::Base.connection_handler.clear_all_connections!
11
+ ::ActiveRecord::Base.connection_handler.clear_all_connections!
12
12
  end
13
13
  end
14
14
  end
@@ -17,16 +17,12 @@ module Monkey
17
17
  end
18
18
  end
19
19
 
20
- class Monkey::Runner::Fork::Rails
21
- module ActiveRecord
22
- module BasePatch
23
- def dirty_reconnect!
24
- @@connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new
25
- establish_connection
26
- end
27
- end
20
+ ActiveRecord::Base
21
+
22
+ class ActiveRecord::Base
23
+ def self.dirty_reconnect!
24
+ @@connection_handler = ::ActiveRecord::ConnectionAdapters::ConnectionHandler.new
25
+ establish_connection
28
26
  end
29
27
  end
30
28
 
31
- ::ActiveRecord::Base.extend Monkey::Runner::Fork::Rails::ActiveRecord::BasePatch
32
-
@@ -23,19 +23,22 @@ module Monkey
23
23
  raise ArgumentError, 'block must be provided' unless block_given?
24
24
  pid = fork do
25
25
  trap('TERM') do
26
- Monkey.logger.warn "Process #{Process.pid} received SIGTERM, will exit!"
26
+ Monkey.logger.warn "Process #{Process.pid} received SIGTERM, will exit!(2)"
27
27
  exit!(2)
28
28
  end
29
- ActiveRecord::Base.spawn_reconnect
30
29
  begin
30
+ Monkey.logger.debug "Process #{Process.pid} running"
31
31
  yield(*args)
32
+ Monkey.logger.debug "Process #{Process.pid} will exit!"
32
33
  exit!(0)
33
34
  rescue
34
35
  Monkey.logger.error $!
36
+ Monkey.logger.error "Process #{Process.pid} failed, will exit!(1)"
35
37
  exit!(1)
36
38
  end
37
39
  end
38
40
  (spid = Process.detach(pid))[:pid] = pid
41
+ Monkey.logger.debug "Forked #{pid}"
39
42
  spid
40
43
  end
41
44
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipa-monkeyjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Gunko