mamiya 0.2.3 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: aa5600d98b716ed7b4a4bf9ba0a4c8e9b8e5d79c
4
- data.tar.gz: 6af95ad395f75cdc35bb6b433fdc3f415409683c
3
+ metadata.gz: 900d91f672af5554eea950816c4e6dd8f24d93e3
4
+ data.tar.gz: 72a64125e25bbba31333248aa336ebe7996446cc
5
5
  SHA512:
6
- metadata.gz: 3047ad5f502c4207c3b4b86cc2f95d88711ab188df5a1de042616157964a7a7d210e486261ed323b468fb1cc84dc321ff47284c227508551f3f95a7fb2888e4f
7
- data.tar.gz: 5947558c626dadbe7396f5312907ee96b1823407d8ec7a458426f01d6826e113f5bb7c4cea6e08a033b67255c761e9e6edd5823eb79656da23d7f5d002be0011
6
+ metadata.gz: a0e992317d9e565cc8880e200554917a0561fae6b3e7a42e3c4a9991f4e7501dbc78a361207781add2bdf1232cef46b925df6d84910d91b4e10bf4d31afe8ed2
7
+ data.tar.gz: e0bc6292faa73ecb0c630da6fc7738457162d9a7d0b3d4870c8c616a9683879c91bf2a8e8a2078c326e4d36873053b1faf0b38770ff7fe2a67cfa074d5e958d7
@@ -1,8 +1,9 @@
1
1
  language: ruby
2
+ sudo: false
2
3
  cache: bundler
3
4
  rvm:
4
- - "2.2"
5
- - "2.1"
5
+ - "2.2.3"
6
+ - "2.1.7"
6
7
  - "2.0.0"
7
8
  - "ruby-head"
8
9
 
@@ -0,0 +1,5 @@
1
+ # FAQs
2
+
3
+ ## What is good when using Mamiya instead of using Serf/Consul directly?
4
+
5
+ Mamiya tracks all nodes status. -- e.g. you can know which node is having different version from others
@@ -57,7 +57,7 @@ set :web, {
57
57
  #### Run it
58
58
 
59
59
  ```
60
- mamiya master -c /etc/mamiya/config.rb
60
+ mamiya master -C /etc/mamiya/config.rb
61
61
  ```
62
62
 
63
63
  ### Agent
@@ -112,7 +112,7 @@ end
112
112
  #### Run it
113
113
 
114
114
  ```
115
- mamiya master -c /etc/mamiya/config.rb
115
+ mamiya agent -C /etc/mamiya/config.rb
116
116
  ```
117
117
 
118
118
  ### Confirm both working
@@ -163,7 +163,7 @@ end
163
163
  # Step `release` run when Release is required. Usually for restarting app process, etc.
164
164
  # Also these step declaration accepts labels for `only` and `except` key to limit agents to run on.
165
165
  # (Labels can be set by agent's configuration)
166
- release 'reload unicorn', only [:app] do
166
+ release 'reload unicorn', only: [:app] do
167
167
  run 'pkill', '-HUP', '-f', 'unicorn'
168
168
  end
169
169
  ```
@@ -190,7 +190,7 @@ Great! You can unpack using `tar xf` to confirm what has packed, if you want.
190
190
  You have to push it onto storage to make available for agents.
191
191
 
192
192
  ```
193
- $ mamiya push -C ./config.rb
193
+ $ mamiya push -C ./config.rb builds/20141118093701-myapp.tar.gz
194
194
  11/18 09:42:43 INFO [Push] Pushing builds/20141118093701-myapp.tar.gz to storage(app=myapp)...
195
195
  11/18 09:42:43 INFO [Push] DONE!
196
196
  ```
@@ -125,7 +125,6 @@ module Mamiya
125
125
  target: release_path,
126
126
  config: config,
127
127
  logger: logger,
128
- config: config,
129
128
  labels: agent.labels,
130
129
  no_release: !!task['no_release'],
131
130
  do_release: !!task['do_release'],
@@ -88,6 +88,7 @@ module Mamiya
88
88
  method_option :build_to, aliases: %w(--destination -t), type: :string
89
89
  method_option :skip_prepare_build, aliases: %w(--no-prepare-build -P), type: :boolean
90
90
  method_option :force_prepare_build, aliases: %w(--prepare-build -p), type: :boolean
91
+ method_option :push, aliases: %w(--push), type: :boolean
91
92
  def build
92
93
  # TODO: overriding name
93
94
  %i(build_from build_to).each { |k| script.set(k, File.expand_path(options[k])) if options[k] }
@@ -105,7 +106,13 @@ module Mamiya
105
106
  script.set :skip_prepare_build, true
106
107
  end
107
108
 
108
- Mamiya::Steps::Build.new(script: script, logger: logger).run!
109
+ builder = Mamiya::Steps::Build.new(script: script, logger: logger)
110
+ builder.run!
111
+
112
+ if options[:push]
113
+ package = builder.package
114
+ push(package.name)
115
+ end
109
116
  end
110
117
 
111
118
  desc "push PACKAGE", "Upload built packages to storage."
@@ -60,12 +60,15 @@ module Mamiya
60
60
  run_id = generate_run_id()
61
61
  logger = self.logger["run:#{run_id}"]
62
62
 
63
- logger.info("$ #{args.shelljoin}")
63
+ env = args.last.is_a?(Hash) ? args.pop : {}
64
+ shellenv = env.empty? ? nil : "#{escape_env(env)} "
65
+
66
+ logger.info("$ #{shellenv}#{args.shelljoin}")
64
67
 
65
68
  err_r, err_w = IO.pipe
66
69
  out_r, out_w = IO.pipe
67
70
 
68
- pid = spawn(*args, out: out_w, err: err_w)
71
+ pid = spawn(env, *args.map(&:to_s), out: out_w, err: err_w)
69
72
 
70
73
  [out_w, err_w].each(&:close)
71
74
 
@@ -76,7 +79,7 @@ module Mamiya
76
79
  Thread.new {
77
80
  until io.eof?
78
81
  str = io.gets
79
- logger.__send__(severity, str.chomp)
82
+ logger.__send__(severity, " #{str.chomp}")
80
83
  buf << str
81
84
  last_out = Time.now
82
85
  end
@@ -87,7 +90,7 @@ module Mamiya
87
90
  l = logger['timekeeper']
88
91
  loop do
89
92
  if 90 < (Time.now - last_out)
90
- l.warn "pid #{pid} still running; since #{started_at}"
93
+ l.warn "pid #! {pid} still running; since #{started_at}"
91
94
  end
92
95
  sleep 60
93
96
  end
@@ -98,7 +101,7 @@ module Mamiya
98
101
  timekeeper_th.kill if timekeeper_th.alive?
99
102
 
100
103
  begin
101
- timeout(3) { ths.each(&:join) }
104
+ Timeout.timeout(3) { ths.each(&:join) }
102
105
  rescue Timeout::Error
103
106
  end
104
107
  ths.each { |_| _.alive? && _.kill }
@@ -118,7 +121,7 @@ module Mamiya
118
121
 
119
122
  end
120
123
 
121
- logger.info "pid #{pid} completed: #{args.inspect}"
124
+ logger.info "* pid #{pid} completed: #{args.inspect}"
122
125
 
123
126
  buf
124
127
  end
@@ -177,5 +180,11 @@ module Mamiya
177
180
  id
178
181
  end
179
182
  end
183
+
184
+ def escape_env(hash)
185
+ hash.map { |key, value|
186
+ [key.to_s.shellescape, value.to_s.shellescape].join("=")
187
+ }.join(" ")
188
+ end
180
189
  end
181
190
  end
@@ -51,6 +51,10 @@ module Mamiya
51
51
  end
52
52
  end
53
53
 
54
+ def package
55
+ @package ||= Mamiya::Package.new(package_path)
56
+ end
57
+
54
58
  private
55
59
 
56
60
  def run_before_build
@@ -140,10 +144,6 @@ module Mamiya
140
144
  @package_path ||= File.join(script.build_to, package_name)
141
145
  end
142
146
 
143
- def package
144
- @package ||= Mamiya::Package.new(package_path)
145
- end
146
-
147
147
  def script_file
148
148
  @script_file ||= script.script_file || script._file
149
149
  end
@@ -1,3 +1,3 @@
1
1
  module Mamiya
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -37,6 +37,18 @@ describe Mamiya::Script do
37
37
  .from(false).to(true)
38
38
  end
39
39
 
40
+ context "when given environment variables" do
41
+ it "runs command with environment variables" do
42
+ output = script.run("env", { "foo" => "bar" })
43
+ expect(output).to include("foo=bar")
44
+ end
45
+
46
+ it "logs environment variables with command" do
47
+ script.run("env", { "foo" => "bar" })
48
+ expect(log).to include([:info, "$ foo=bar env"])
49
+ end
50
+ end
51
+
40
52
  context "when the command failed" do
41
53
  it "logs error" do
42
54
  begin
@@ -68,12 +80,12 @@ describe Mamiya::Script do
68
80
 
69
81
  it "logs stdout as info" do
70
82
  script.run("echo", "foo")
71
- expect(log).to include([:info, "foo"])
83
+ expect(log).to include([:info, " foo"])
72
84
  end
73
85
 
74
86
  it "logs stderr as warn" do
75
87
  script.run("ruby", "-e", "warn 'bar'")
76
- expect(log).to include([:warn, "bar"])
88
+ expect(log).to include([:warn, " bar"])
77
89
  end
78
90
 
79
91
  it "returns captured output as String" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mamiya
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shota Fukumori (sora_h)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-09-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -180,6 +180,7 @@ files:
180
180
  - README.md
181
181
  - Rakefile
182
182
  - bin/mamiya
183
+ - docs/faq.md
183
184
  - docs/internal/serf_events.md
184
185
  - docs/internal/serf_queries.md
185
186
  - docs/internal/tasks.md
@@ -299,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
299
300
  version: '0'
300
301
  requirements: []
301
302
  rubyforge_project:
302
- rubygems_version: 2.4.1
303
+ rubygems_version: 2.5.0
303
304
  signing_key:
304
305
  specification_version: 4
305
306
  summary: Fast deploy tool using tarballs and serf