myreplicator 1.1.17 → 1.1.18

Sign up to get free protection for your applications and to get access to all the features.
@@ -91,7 +91,30 @@ module Myreplicator
91
91
 
92
92
  return false
93
93
  end
94
+
95
+ ##
96
+ # Clear all logs marked running that have run for more than 2 hours
97
+ ##
98
+ def self.clear_stucks
99
+ runnings = Log.where(:state => "running")
100
+ news = Log.where(:state => "new")
101
+ logs = runnings + news
102
+
103
+ if logs.count > 0
104
+ logs.each do |log|
105
+ time_start = log.started_at
106
+ now = Time.now()
107
+ if time_start + 2.hour < now
108
+ Process.kill('KILL', log.pid)
109
+ log.state = "killed"
110
+ log.save!
111
+ end
112
+ end
113
+ end
114
+
115
+ end
94
116
 
117
+
95
118
  ##
96
119
  # Clear all logs marked running that are not running
97
120
  ##
@@ -101,7 +124,7 @@ module Myreplicator
101
124
  if logs.count > 0
102
125
  logs.each do |log|
103
126
  begin
104
- Process.getpgid(log.pid) if hostname == Socket.gethostname
127
+ Process.getpgid(log.pid) if log.hostname == Socket.gethostname
105
128
  rescue Errno::ESRCH
106
129
  log.mark_dead
107
130
  end
@@ -0,0 +1,18 @@
1
+ require "log"
2
+
3
+ module Myreplicator
4
+ class Sweeper
5
+
6
+ @queue = :myreplicator_sweeper # Provided for Resque
7
+
8
+ ##
9
+ # Main method provided for resque
10
+ # Reconnection provided for resque workers
11
+ ##
12
+ def self.perform
13
+ Myreplicator::Log.clear_deads
14
+ Myreplicator::Log.clear_stucks
15
+ end
16
+
17
+ end
18
+ end
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.1.17"
2
+ VERSION = "1.1.18"
3
3
  end
@@ -112,7 +112,7 @@ module Myreplicator
112
112
  end
113
113
  end
114
114
  end #if
115
- puts "#{Thread.current.to_s}___Exiting download..."
115
+ #puts "#{Thread.current.to_s}___Exiting download..."
116
116
  end
117
117
  }
118
118
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: myreplicator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.17
4
+ version: 1.1.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-23 00:00:00.000000000 Z
12
+ date: 2013-03-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -203,6 +203,7 @@ files:
203
203
  - app/helpers/myreplicator/exports_helper.rb
204
204
  - app/models/myreplicator/export.rb
205
205
  - app/models/myreplicator/log.rb
206
+ - app/models/myreplicator/sweeper.rb
206
207
  - app/models/myreplicator/vertica_export.rb
207
208
  - app/views/layouts/myreplicator/application.html.erb
208
209
  - app/views/myreplicator/exports/_form.html.erb
@@ -356,7 +357,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
356
357
  version: '0'
357
358
  segments:
358
359
  - 0
359
- hash: -2747593640282198801
360
+ hash: -2961374731451743884
360
361
  required_rubygems_version: !ruby/object:Gem::Requirement
361
362
  none: false
362
363
  requirements:
@@ -365,7 +366,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
365
366
  version: '0'
366
367
  segments:
367
368
  - 0
368
- hash: -2747593640282198801
369
+ hash: -2961374731451743884
369
370
  requirements: []
370
371
  rubyforge_project:
371
372
  rubygems_version: 1.8.24