bricolage 5.22.0 → 5.22.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6894dfe2fad736476fc5c77d3e9f271d211e9e7
4
- data.tar.gz: 7121e86bc937c14b91cbcfe3035dcde4e08aa027
3
+ metadata.gz: d23da6e1aee97530773a60aafdb8f521b5b59685
4
+ data.tar.gz: d2558688f61f529f8ea19e0a5d902e0e6d558bf6
5
5
  SHA512:
6
- metadata.gz: 46411897c454153c4dd2b726a6d9427fe49b3ab8eb4157e2d3054ba09e623709727ddec5124be46ae02777b0c7da3c037b2a2d253dec7a68680ced7dadf96c3b
7
- data.tar.gz: 4fe3715fee1220d98eecab7cbe1e3cdd1fe89ee14f19008017dc1f8aea0ad1ca81507f25c8026551098246fce31ddd4a8af720cc9bab2de94ce8ad5c9e7ff231
6
+ metadata.gz: ff04d18f0ae2d91cf6b79811e1390848ddf3ba070a459b924a2e93766bcbd460ddb49520a0fa0d51a3a2f9486f581d04bc560c1dbd4397ebbd4e4617b8371982
7
+ data.tar.gz: da630e751c5a614bf13a70f992d4025782741a80db0e7c0ba5ade16ea62ea5c131709fc4aa1e20084dcc6bc9a380b331c8dff16c70014c223bfc1bdfefed8f70
@@ -38,7 +38,7 @@ module Bricolage
38
38
  opts = Options.new(self)
39
39
  @hooks.run_before_option_parsing_hooks(opts)
40
40
  opts.parse ARGV
41
- @ctx = Context.for_application(nil, opts.jobnet_file, environment: opts.environment, global_variables: opts.global_variables)
41
+ @ctx = Context.for_application(job_path: opts.jobnet_file, environment: opts.environment, global_variables: opts.global_variables)
42
42
  @jobnet_id = "#{opts.jobnet_file.dirname.basename}/#{opts.jobnet_file.basename('.jobnet')}"
43
43
  @log_path = opts.log_path
44
44
  jobnet =
@@ -53,7 +53,7 @@ module Bricolage
53
53
  end
54
54
  unless queue.queued?
55
55
  enqueue_jobs jobnet, queue
56
- logger.info "jobs are queued." if opts.queue_exist?
56
+ logger.info "jobs are queued."
57
57
  end
58
58
  if opts.list_jobs?
59
59
  list_jobs queue
@@ -79,13 +79,32 @@ module Bricolage
79
79
  end
80
80
 
81
81
  def get_queue(opts)
82
- if opts.queue_path
83
- FileTaskQueue.restore_if_exist(opts.queue_path)
82
+ if path = get_queue_file_path(opts)
83
+ logger.info "queue path: #{path}"
84
+ FileTaskQueue.restore_if_exist(path)
84
85
  else
85
86
  TaskQueue.new
86
87
  end
87
88
  end
88
89
 
90
+ def get_queue_file_path(opts)
91
+ if opts.queue_path
92
+ opts.queue_path
93
+ elsif opts.enable_queue?
94
+ opts.local_state_dir + 'queue' + "#{app_name}.#{@jobnet_id.tr('/', '.')}"
95
+ else
96
+ nil
97
+ end
98
+ end
99
+
100
+ def app_name
101
+ path = @ctx.home_path.realpath
102
+ while /\A(?:\d+|current|releases)\z/ =~ path.basename.to_s # is Capistrano dirs
103
+ path = path.dirname
104
+ end
105
+ path.basename.to_s
106
+ end
107
+
89
108
  def enqueue_jobs(jobnet, queue)
90
109
  seq = 1
91
110
  jobnet.sequential_jobs.each do |ref|
@@ -176,7 +195,17 @@ module Bricolage
176
195
  @environment = nil
177
196
  @jobnet_files = nil
178
197
  @log_path = LogFilePath.default
179
- @queue_path = nil
198
+ @local_state_dir = Pathname('/tmp/bricolage')
199
+ if path = ENV['BRICOLAGE_QUEUE_PATH']
200
+ @enable_queue = true
201
+ @queue_path = Pathname(path)
202
+ elsif ENV['BRICOLAGE_ENABLE_QUEUE']
203
+ @enable_queue = true
204
+ @queue_path = nil
205
+ else
206
+ @enable_queue = false
207
+ @queue_path = nil
208
+ end
180
209
  @check_only = false
181
210
  @list_jobs = false
182
211
  @global_variables = Variables.new
@@ -186,13 +215,16 @@ module Bricolage
186
215
 
187
216
  attr_reader :environment
188
217
  attr_reader :jobnet_file
189
- attr_reader :queue_path
190
218
  attr_reader :log_path
191
219
 
192
- def queue_exist?
193
- !!@queue_path
220
+ attr_reader :local_state_dir
221
+
222
+ def enable_queue?
223
+ @enable_queue
194
224
  end
195
225
 
226
+ attr_reader :queue_path
227
+
196
228
  def check_only?
197
229
  @check_only
198
230
  end
@@ -222,7 +254,13 @@ Options:
222
254
  parser.on('--log-path=PATH', 'Log file path template.') {|path|
223
255
  @log_path = LogFilePath.new(path)
224
256
  }
225
- parser.on('--queue=PATH', 'Use job queue.') {|path|
257
+ parser.on('--local-state-dir=PATH', 'Stores local state in this path.') {|path|
258
+ @local_state_dir = Pathname(path)
259
+ }
260
+ parser.on('--enable-queue', 'Enables job queue.') {
261
+ @enable_queue = true
262
+ }
263
+ parser.on('--queue-path=PATH', 'Enables job queue with this path.') {|path|
226
264
  @queue_path = Pathname(path)
227
265
  }
228
266
  parser.on('-c', '--check-only', 'Checks job parameters and quit without executing.') {
@@ -1,5 +1,6 @@
1
1
  require 'bricolage/jobnet'
2
2
  require 'bricolage/exception'
3
+ require 'fileutils'
3
4
  require 'pathname'
4
5
 
5
6
  module Bricolage
@@ -92,6 +93,7 @@ module Bricolage
92
93
  @path.unlink if @path.exist?
93
94
  return
94
95
  end
96
+ FileUtils.mkdir_p @path.dirname
95
97
  tmpname = "#{@path}.tmp.#{Process.pid}"
96
98
  begin
97
99
  File.open(tmpname, 'w') {|f|
@@ -1,4 +1,4 @@
1
1
  module Bricolage
2
2
  APPLICATION_NAME = 'Bricolage'
3
- VERSION = '5.22.0'
3
+ VERSION = '5.22.1'
4
4
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- bricolage (5.22.0)
4
+ bricolage (5.22.1)
5
5
  aws-sdk (~> 2)
6
6
  mysql2
7
7
  pg (~> 0.18.0)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricolage
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.22.0
4
+ version: 5.22.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki