barbeque 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/barbeque/config.rb +37 -0
- data/lib/barbeque/exception_handler.rb +1 -1
- data/lib/barbeque/runner.rb +3 -2
- data/lib/barbeque/runner/hako.rb +46 -0
- data/lib/barbeque/version.rb +1 -1
- metadata +5 -18
- data/lib/barbeque/configuration.rb +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e9cf425229aa453c69b0b10724cd42f16d3d5a9
|
4
|
+
data.tar.gz: d8434e65e0d541f19b5424ffe906fa1519999f83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a751d7a94159f26dab6a2b434af7dc47a4e826657d7c3d7ebb33b67174eddf9104bd7b1f80d6fd5397ce82b7a5905c7c55a4424d3e7e14da63f7fe12aa7d356e
|
7
|
+
data.tar.gz: e18f9585c6a98e66c4b0285912c6ad8a7079f39d5a8dc3b4fab066652d29b9a4aecec0a70ee71ccfa2eb8d1372641e01670792feebcffee6ac690bfc873d4d52
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Barbeque
|
5
|
+
class Config
|
6
|
+
attr_accessor :exception_handler, :runner, :runner_options
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
options.each do |key, value|
|
10
|
+
if respond_to?("#{key}=")
|
11
|
+
public_send("#{key}=", value)
|
12
|
+
else
|
13
|
+
raise KeyError.new("Unexpected option '#{key}' was specified.")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
runner_options.symbolize_keys!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
module ConfigBuilder
|
21
|
+
DEFAULT_CONFIG = {
|
22
|
+
'exception_handler' => 'RailsLogger',
|
23
|
+
'runner' => 'Docker',
|
24
|
+
'runner_options' => {},
|
25
|
+
}
|
26
|
+
|
27
|
+
def config
|
28
|
+
@config ||= build_config
|
29
|
+
end
|
30
|
+
|
31
|
+
def build_config(config_name = 'barbeque')
|
32
|
+
Config.new(DEFAULT_CONFIG.merge(Rails.application.config_for(config_name)))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
extend ConfigBuilder
|
37
|
+
end
|
data/lib/barbeque/runner.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
-
require 'barbeque/
|
1
|
+
require 'barbeque/config'
|
2
2
|
require 'barbeque/runner/docker'
|
3
|
+
require 'barbeque/runner/hako'
|
3
4
|
|
4
5
|
module Barbeque
|
5
6
|
module Runner
|
6
7
|
# @param [Barbeque::DockerImage] docker_image
|
7
8
|
def self.create(docker_image:)
|
8
9
|
klass = const_get(Barbeque.config.runner, false)
|
9
|
-
klass.new(docker_image: docker_image)
|
10
|
+
klass.new(Barbeque.config.runner_options.merge(docker_image: docker_image))
|
10
11
|
end
|
11
12
|
end
|
12
13
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'open3'
|
2
|
+
|
3
|
+
module Barbeque
|
4
|
+
module Runner
|
5
|
+
class Hako
|
6
|
+
# @param [Barbeque::DockerImage] docker_image
|
7
|
+
# @param [String] hako_dir
|
8
|
+
# @param [Hash] hako_env
|
9
|
+
# @param [String] yaml_dir
|
10
|
+
def initialize(docker_image:, hako_dir:, hako_env: {}, yaml_dir:)
|
11
|
+
@app_name = docker_image.repository
|
12
|
+
@tag = docker_image.tag
|
13
|
+
@hako_dir = hako_dir
|
14
|
+
@hako_env = hako_env
|
15
|
+
@yaml_dir = yaml_dir
|
16
|
+
end
|
17
|
+
|
18
|
+
# @param [Array<String>] command
|
19
|
+
# @param [Hash] envs
|
20
|
+
# @return [String] stdout
|
21
|
+
# @return [String] stderr
|
22
|
+
# @return [Process::Status] status
|
23
|
+
def run(command, envs)
|
24
|
+
cmd = build_hako_oneshot_command(command, envs)
|
25
|
+
Bundler.with_clean_env do
|
26
|
+
Open3.capture3(@hako_env, *cmd, chdir: @hako_dir)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def build_hako_oneshot_command(command, envs)
|
33
|
+
[
|
34
|
+
'bundle', 'exec', 'hako', 'oneshot', '--tag', @tag,
|
35
|
+
*env_options(envs), File.join(@yaml_dir, "#{@app_name}.yml"), '--', *command,
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
def env_options(envs)
|
40
|
+
envs.map do |key, value|
|
41
|
+
"--env=#{key}=#{value}"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/barbeque/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barbeque
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takashi Kokubun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: adminlte2-rails
|
@@ -66,20 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: hashie
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: jquery-rails
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -359,7 +345,7 @@ files:
|
|
359
345
|
- db/migrate/20160516041710_create_job_retries.rb
|
360
346
|
- db/migrate/20160829023237_prefix_barbeque_to_tables.rb
|
361
347
|
- lib/barbeque.rb
|
362
|
-
- lib/barbeque/
|
348
|
+
- lib/barbeque/config.rb
|
363
349
|
- lib/barbeque/docker_image.rb
|
364
350
|
- lib/barbeque/engine.rb
|
365
351
|
- lib/barbeque/exception_handler.rb
|
@@ -375,6 +361,7 @@ files:
|
|
375
361
|
- lib/barbeque/message_queue.rb
|
376
362
|
- lib/barbeque/runner.rb
|
377
363
|
- lib/barbeque/runner/docker.rb
|
364
|
+
- lib/barbeque/runner/hako.rb
|
378
365
|
- lib/barbeque/slack_client.rb
|
379
366
|
- lib/barbeque/version.rb
|
380
367
|
- lib/barbeque/worker.rb
|
@@ -400,7 +387,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
400
387
|
version: '0'
|
401
388
|
requirements: []
|
402
389
|
rubyforge_project:
|
403
|
-
rubygems_version: 2.5.
|
390
|
+
rubygems_version: 2.5.2
|
404
391
|
signing_key:
|
405
392
|
specification_version: 4
|
406
393
|
summary: Job queue system to run job with Docker
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'yaml'
|
3
|
-
require 'hashie'
|
4
|
-
|
5
|
-
module Barbeque
|
6
|
-
module Configuration
|
7
|
-
DEFAULT_CONFIG = {
|
8
|
-
'exception_handler' => 'RailsLogger',
|
9
|
-
'runner' => 'Docker',
|
10
|
-
}
|
11
|
-
|
12
|
-
def config
|
13
|
-
@config ||= build_config
|
14
|
-
end
|
15
|
-
|
16
|
-
def build_config
|
17
|
-
filename = Rails.root.join('config', 'barbeque.yml').to_s
|
18
|
-
hash = YAML.load(ERB.new(File.read(filename)).result)
|
19
|
-
Hashie::Mash.new(DEFAULT_CONFIG.merge(hash[Rails.env]))
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
extend Configuration
|
24
|
-
end
|