batch_manager 0.2.6 → 0.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZGRhOWQ1ZmJhMmU4Nzg3NzJhMmExMWM3ZTZhOWRmYjM0YmFkZTU4NA==
4
+ M2M2ODYwMWZjOWY0NjQyZTZiN2ExYjk2MTAyYzk3MzVkZTc4Mzk0Mw==
5
5
  data.tar.gz: !binary |-
6
- Y2U4MGYxY2MwYTI4OGMzNmJiNjJmZTE5Yjg5YjZjOWQzNDcwNjZjZQ==
6
+ MjliZTg3YzE4Mzk5ZjZkZjgxY2U3MmE4MDBkNzhiYmM1Y2QzYmI5Ng==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- Y2YyMDgyNWE3MmYzYTYxMzg3ZTA1Y2Y2NDRhN2M5MjNmMmE4YTE2YWVhYThi
10
- OTI1MDVhNzc0OGNlNDk5OTA3MDBlZWJmOTgwNTllYjI3MDVkYjI4NzZhNjRl
11
- OTBmZjc1YWIzMThiNGM0ZWMyNWZlYWNhYTk0ZDQxOWI2YWM3MWI=
9
+ ODZkMzU2MDQ1NWM0NWZjZTljOGRiM2M0NWVlMDc1ZWNhMDQzNDViZWM5NWJl
10
+ ZjE3YzkxMzE5ZDE2NjYxZWQxNWI4MWE3NGZkMDNjNGI4NDg0MjhhZTJiMzIw
11
+ YjE2YWRkMGYwNzIxMTFiNjlkNDc4NTBlZWM4ZGM3OTlmMjQ5N2Y=
12
12
  data.tar.gz: !binary |-
13
- MTYzNzhhNWM1ZWE2NTk0MDAwYjk2M2NjZDk2ZTFlMjJjODQ3ZmI3ZTdjNjRm
14
- ZGRhNzEwMWVkODFhZmQzMWM1Y2U0NzRhZjE2ZTEzZDY1MjgxZGIyNDIxZjdl
15
- YzViOWUzN2U2Y2U5MDJmNTZlZDI0MDlhNGFmNTc0MjkxM2E5MmY=
13
+ YzI1YWYwMWFmZjEwOThkNDFjODYxOTIwMGMwN2Q2NzMxM2MyN2I5YmExYzZl
14
+ OGFlYjc4NTg4NDY5NDE0OTk5ZjdjNTJkZWFmZWMwNjg2MDg0NWQ1OTZlMjhi
15
+ NjJlOTgyMjk0YTM4NmFhMmUzZmQ5NjllMTcxYjUyMmY5NGUyZTc=
@@ -1,15 +1,15 @@
1
1
  module BatchManager
2
2
  class BatchesController < ApplicationController
3
+ before_filter :retain_batch_params, :except => [:index]
4
+
3
5
  def index
4
6
  @details = BatchManager::Monitor.details
5
7
  end
6
8
 
7
9
  def exec
8
- @batch_name = params[:batch_name]
9
- @wet = params[:wet]
10
10
  if resque_supported?
11
11
  Resque.enqueue(BatchManager::ExecBatchWorker, @batch_name, :wet => @wet)
12
- @offset = log_file.size
12
+ redirect_to(log_batches_url(:batch_name => @batch_name, :wet => @wet))
13
13
  else
14
14
  BatchManager::Executor.exec(@batch_name, :wet => @wet)
15
15
  redirect_to(batches_url)
@@ -17,18 +17,22 @@ module BatchManager
17
17
  end
18
18
 
19
19
  def async_read_log
20
- file = log_file
21
- file.seek(params[:offset].to_i) if params[:offset].present?
22
- render :json => {:content => file.read, :offset => file.size}
20
+ log_file.seek(params[:offset].to_i) if params[:offset].present?
21
+ render :json => {:content => log_file.read, :offset => log_file.size}
23
22
  end
24
23
 
25
24
  def log
26
- log_file = BatchManager::Logger.log_file_path(params[:batch_name], params[:wet])
27
- render :file => log_file, :content_type => Mime::TEXT, :layout => false
25
+ @offset = log_file.size
26
+ @content = log_file.read
28
27
  end
29
28
 
30
29
  private
31
30
 
31
+ def retain_batch_params
32
+ @batch_name = params[:batch_name]
33
+ @wet = params[:wet]
34
+ end
35
+
32
36
  def resque_supported?
33
37
  begin
34
38
  require 'resque'
@@ -39,7 +43,15 @@ module BatchManager
39
43
  end
40
44
 
41
45
  def log_file
42
- File.open(BatchManager::Logger.log_file_path(params[:batch_name], params[:wet]), 'r')
46
+ 20.times do
47
+ begin
48
+ @log_file ||= File.open(BatchManager::Logger.log_file_path(@batch_name, @wet), 'r')
49
+ return @log_file
50
+ rescue
51
+ sleep 3
52
+ retry
53
+ end
54
+ end
43
55
  end
44
56
  end
45
57
  end
@@ -16,7 +16,7 @@
16
16
  });
17
17
  </script>
18
18
 
19
- <h2><%= @batch_name %> <%= "WET RUN" if @wet %> Executing!<h2>
19
+ <h2><%= @batch_name %><h2>
20
20
 
21
- <%= text_area_tag :log, nil, :id => "log_box" %>
21
+ <%= text_area_tag :log, @content, :id => "log_box" %>
22
22
  <%= hidden_field_tag :offset, @offset, :id => :offset %>
@@ -1,3 +1,3 @@
1
1
  module BatchManager
2
- VERSION = "0.2.6"
2
+ VERSION = "0.2.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: batch_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Weihu Chen
@@ -122,8 +122,8 @@ files:
122
122
  - app/assets/stylesheets/batch_manager/batches.css
123
123
  - app/controllers/batch_manager/application_controller.rb
124
124
  - app/controllers/batch_manager/batches_controller.rb
125
- - app/views/batch_manager/batches/exec.html.erb
126
125
  - app/views/batch_manager/batches/index.html.erb
126
+ - app/views/batch_manager/batches/log.html.erb
127
127
  - app/views/layouts/batch_manager/application.html.erb
128
128
  - app/workers/batch_manager/exec_batch_worker.rb
129
129
  - config/routes.rb