myreplicator 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -585,3 +585,17 @@ table.overview tr:nth-child(even) {background:#fbfbfb;}
585
585
  table.overview tr:last-child td {border-bottom:0px;}
586
586
  table.overview td span.name {color:#474747;display:block;font-weight:bold; font-size:13px;padding-bottom:5px;}
587
587
  table.overview td span.file {color:#999;display:block;font-style:italic;}
588
+ a.kill {
589
+ color:#474747;
590
+ display:block;
591
+ float:right;
592
+ text-decoration:none;
593
+ text-shadow:0 1px #fff;
594
+ }
595
+ a.kill:before {
596
+ content: '`';
597
+ font-family: 'WebSymbolsRegular';
598
+ padding-right:3px;
599
+ font-size:14px;
600
+ }
601
+ a.kill:hover:before {color:#990000}
@@ -47,22 +47,18 @@ module Myreplicator
47
47
  @edit = true
48
48
 
49
49
  Myreplicator::Export.schedule_in_resque # schedule in resque
50
-
51
50
  end
52
51
 
53
52
  # POST /exports
54
53
  # POST /exports.json
55
54
  def create
56
55
  @export = Export.new(params[:export])
57
-
58
- Myreplicator::Export.schedule_in_resque # schedule in resque
59
-
60
56
  @dbs = get_dbs
61
-
62
57
  respond_to do |format|
63
58
  if @export.save
64
59
  format.html { redirect_to @export, notice: 'Export was successfully created.' }
65
60
  format.json { render json: @export, status: :created, location: @export }
61
+ Myreplicator::Export.schedule_in_resque # schedule in resque
66
62
  else
67
63
  format.html { render action: "new" }
68
64
  format.json { render json: @export.errors, status: :unprocessable_entity }
@@ -21,6 +21,12 @@ module Myreplicator
21
21
  @exports = Export.where("error is not null").order('source_schema ASC')
22
22
  @logs = Log.where(:state => 'error').order("started_at DESC")
23
23
  end
24
+
25
+ def kill
26
+ @log = Log.find(params[:id])
27
+ @log.kill
28
+ redirect_to :action => 'index'
29
+ end
24
30
 
25
31
  end
26
32
  end
@@ -76,7 +76,7 @@ module Myreplicator
76
76
  :table => self.table_name)
77
77
  result = exec_on_source(sql)
78
78
 
79
- return result.first.first
79
+ return result.first.first.to_s(:db)
80
80
  end
81
81
 
82
82
  def update_max_val(max_val = nil)
@@ -68,7 +68,11 @@ module Myreplicator
68
68
  # Checks to see if the PID of the log is active or not
69
69
  ##
70
70
  def running?
71
- logs = Log.where(:file => file, :job_type => job_type, :state => "running")
71
+ logs = Log.where(:file => file,
72
+ :job_type => job_type,
73
+ :state => "running",
74
+ :export_id => export_id,
75
+ :hostname => hostname)
72
76
 
73
77
  if logs.count > 0
74
78
  logs.each do |log|
@@ -12,6 +12,7 @@
12
12
  <td><%= log.job_type %></td>
13
13
  <td><%= log.started_at.strftime("%Y-%m-%d %H:%M:%S") %></td>
14
14
  <td><%= chronos(@now.to_i - log.started_at.to_i) %></td>
15
+ <td><%= link_to 'kill job', kill_path(log), :class => 'kill'%></td>
15
16
  </tr>
16
17
  <% end %>
17
18
  </table>
@@ -31,5 +32,8 @@ jQuery(function(){
31
32
  link.addClass("on");
32
33
  jQuery(link.attr('href')).fadeIn().siblings("li").hide();
33
34
  })
35
+ $("a.kill").click(function(e){
36
+ if(confirm("Are you sure you wish to kill this running job?")!=true){e.preventDefault();}
37
+ })
34
38
  })
35
39
  </script>
data/config/routes.rb CHANGED
@@ -2,4 +2,5 @@ Myreplicator::Engine.routes.draw do
2
2
  resources :exports
3
3
  root :to => "home#index"
4
4
  match '/errors', :to => "home#errors", :as => 'errors'
5
+ match '/kill/:id', :to => 'home#kill', :as => 'kill'
5
6
  end
data/lib/loader/loader.rb CHANGED
@@ -32,7 +32,6 @@ module Myreplicator
32
32
 
33
33
  all_files.each do |m|
34
34
  if m.export_type == "initial"
35
- Kernel.p m
36
35
  initials << m # Add initial to the list
37
36
  all_files.delete(m) # Delete obj from mixed list
38
37
 
@@ -1,3 +1,3 @@
1
1
  module Myreplicator
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -38,8 +38,8 @@ module Myreplicator
38
38
  # downloads export files concurrently from multiple sources
39
39
  ##
40
40
  def self.transfer
41
- unique_jobs = Export.where("state != 'failed' and active = 1").group("source_schema")
42
-
41
+ unique_jobs = Export.where("active = 1").group("source_schema")
42
+
43
43
  unique_jobs.each do |export|
44
44
  download export
45
45
  end
@@ -60,7 +60,7 @@ module Myreplicator
60
60
  ##
61
61
  def self.parallel_download export, ssh, files
62
62
  p = Parallelizer.new(:klass => "Myreplicator::Transporter")
63
-
63
+
64
64
  files.each do |filename|
65
65
  puts filename
66
66
  p.queue << {:params =>[ssh, export, filename], :block => download_file}
@@ -93,7 +93,7 @@ module Myreplicator
93
93
  sftp.download!(json_file, json_local_path)
94
94
  metadata = Transporter.metadata_obj(json_local_path)
95
95
  dump_file = metadata.export_path
96
-
96
+ puts metadata.state
97
97
  if metadata.state == "export_completed"
98
98
  Log.run(:job_type => "transporter", :name => "export_file",
99
99
  :file => dump_file, :export_id => export.id) do |log|