percheron 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +11 -15
- data/examples/consul/.percheron.yml +3 -3
- data/lib/percheron/actions/create.rb +1 -1
- data/lib/percheron/actions/start.rb +29 -9
- data/lib/percheron/commands/purge.rb +1 -1
- data/lib/percheron/formatters/stack/table.rb +2 -0
- data/lib/percheron/unit.rb +6 -2
- data/lib/percheron/unit/image_helper.rb +4 -0
- data/lib/percheron/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bea44fa6bffb36f64cc87ea1b7440f5adec930ee
|
4
|
+
data.tar.gz: f80411ab025ea216f43d8f114160e3d8007e03e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 820eebf1087b9201bd950c3eb989c993389974d0b46b574421516dcaf4cc7ab241b0b077b1894b45191b1be56a56d11faaa54ab055e2ef02601cc4f2a1a11bf9
|
7
|
+
data.tar.gz: 8428c2dc52c9cf6ff2ca82a3a508d9112955b9b5d6cbef68079ffdabd1650def1c6a0263b657fc0830f6e5a173671750813399a7ffd638a0c55458500cd93238
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v0.8.1 / 2015-08-21
|
2
|
+
|
3
|
+
* BUGfix when creating units via Start action
|
4
|
+
* Support needed_unit_names and dependant_unit_names
|
5
|
+
* Added image size to the ascii table for status
|
6
|
+
|
1
7
|
## v0.8.0 / 2015-08-19
|
2
8
|
|
3
9
|
* Hostname is the full `<stack_name>_<name>` by default
|
data/README.md
CHANGED
@@ -81,13 +81,11 @@ Parameters:
|
|
81
81
|
|
82
82
|
Subcommands:
|
83
83
|
list, status List stacks and its units
|
84
|
-
console Start a pry console session
|
85
84
|
start Start a stack
|
86
85
|
stop Stop a stack
|
87
86
|
restart Restart a stack
|
88
|
-
build
|
89
|
-
create
|
90
|
-
recreate Recreate a stack
|
87
|
+
build, rebuild (Re)build image(s) for a stack
|
88
|
+
create, recreate (Re)build image(s) and (re)create units for a stack
|
91
89
|
purge Purge a stack
|
92
90
|
shell Shell into a unit
|
93
91
|
logs Show logs for a unit
|
@@ -96,13 +94,15 @@ Subcommands:
|
|
96
94
|
Options:
|
97
95
|
-h, --help print help
|
98
96
|
-c, --config_file CONFIG Config file (default: ".percheron.yml")
|
99
|
-
--version show
|
97
|
+
--version show versionn
|
100
98
|
```
|
101
99
|
|
102
100
|
## Demo (using boot2docker)
|
103
101
|
|
104
102
|
1) Get boot2docker up and running
|
105
103
|
|
104
|
+
Follow the directions at https://docs.docker.com/installation
|
105
|
+
|
106
106
|
```bash
|
107
107
|
boot2docker up && eval $(boot2docker shellinit) && export BOOT2DOCKER_IP=$(boot2docker ip)
|
108
108
|
```
|
@@ -126,14 +126,14 @@ stacks:
|
|
126
126
|
docker_image: gliderlabs/consul-server:0.5
|
127
127
|
start_args: [ "-bootstrap", "-client", "0.0.0.0", "-data-dir", "/data", "-ui-dir", "/ui" ]
|
128
128
|
ports:
|
129
|
-
- 8500:8500
|
130
|
-
- 8600:53/udp
|
129
|
+
- "8500:8500"
|
130
|
+
- "8600:53/udp"
|
131
131
|
- name: agent
|
132
132
|
version: 1.0.0
|
133
133
|
instances: 2
|
134
134
|
docker_image: gliderlabs/consul-agent:0.5
|
135
135
|
start_args: [ "-join", "master" ]
|
136
|
-
|
136
|
+
needed_unit_names:
|
137
137
|
- master
|
138
138
|
```
|
139
139
|
|
@@ -169,7 +169,7 @@ percheron status consul-stack
|
|
169
169
|
6) Ensure consul is running
|
170
170
|
|
171
171
|
```bash
|
172
|
-
curl http
|
172
|
+
curl http://${BOOT2DOCKER_IP}:8500/v1/catalog/nodes
|
173
173
|
|
174
174
|
[{"Node":"agent1","Address":"172.17.0.5"},{"Node":"agent2","Address":"172.17.0.6"},{"Node":"master","Address":"172.17.0.4"}]
|
175
175
|
```
|
@@ -177,7 +177,7 @@ curl http://boot2docker:8500/v1/catalog/nodes
|
|
177
177
|
7) Perform some DNS lookups using consul
|
178
178
|
|
179
179
|
```bash
|
180
|
-
dig
|
180
|
+
dig @${BOOT2DOCKER_IP} -p 8600 master.node.consul agent1.node.consul agent2.node.consul +short
|
181
181
|
|
182
182
|
172.17.0.7
|
183
183
|
172.17.0.8
|
@@ -187,7 +187,7 @@ dig @boot2docker -p 8600 master.node.consul agent1.node.consul agent2.node.consu
|
|
187
187
|
8) Bring up the consul UI
|
188
188
|
|
189
189
|
```bash
|
190
|
-
open http
|
190
|
+
open http://${BOOT2DOCKER_IP}:8500/ui
|
191
191
|
```
|
192
192
|
|
193
193
|
9) Purge it!
|
@@ -213,10 +213,6 @@ percheron graph consul-stack
|
|
213
213
|
|
214
214
|
![consul-stack](https://raw.githubusercontent.com/ashmckenzie/percheron-consul/master/assets/stack.png)
|
215
215
|
|
216
|
-
## Demo asciicast
|
217
|
-
|
218
|
-
[![asciicast](https://asciinema.org/a/7l1ar35xlmfsaphhptrqvx7jg.png)](https://asciinema.org/a/7l1ar35xlmfsaphhptrqvx7jg)
|
219
|
-
|
220
216
|
## Debugging
|
221
217
|
|
222
218
|
To perform debugging you will need to install the `pry-byebug` gem:
|
@@ -8,12 +8,12 @@ stacks:
|
|
8
8
|
docker_image: gliderlabs/consul-server:0.5
|
9
9
|
start_args: [ "-bootstrap", "-client", "0.0.0.0", "-data-dir", "/data", "-ui-dir", "/ui" ]
|
10
10
|
ports:
|
11
|
-
- 8500:8500
|
12
|
-
- 8600:53/udp
|
11
|
+
- "8500:8500"
|
12
|
+
- "8600:53/udp"
|
13
13
|
- name: agent
|
14
14
|
version: 1.0.0
|
15
15
|
instances: 2
|
16
16
|
docker_image: gliderlabs/consul-agent:0.5
|
17
17
|
start_args: [ "-join", "master" ]
|
18
|
-
|
18
|
+
needed_unit_names:
|
19
19
|
- master
|
@@ -3,17 +3,18 @@ module Percheron
|
|
3
3
|
class Start
|
4
4
|
include Base
|
5
5
|
|
6
|
-
def initialize(unit, needed_units: [], cmd: false, exec_scripts: true)
|
6
|
+
def initialize(unit, needed_units: [], create: true, cmd: false, exec_scripts: true)
|
7
7
|
@unit = unit
|
8
8
|
@needed_units = needed_units
|
9
|
+
@create = create
|
9
10
|
@cmd = cmd
|
10
11
|
@exec_scripts = exec_scripts
|
11
12
|
end
|
12
13
|
|
13
14
|
def execute!
|
14
|
-
|
15
|
-
results
|
16
|
-
|
15
|
+
return nil if unit.running?
|
16
|
+
results = [ create! ]
|
17
|
+
if unit.startable?
|
17
18
|
results << start!
|
18
19
|
results << execute_post_start_scripts!
|
19
20
|
end
|
@@ -22,21 +23,40 @@ module Percheron
|
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
|
-
attr_reader :unit, :needed_units, :cmd, :exec_scripts
|
26
|
+
attr_reader :unit, :needed_units, :create, :cmd, :exec_scripts
|
27
|
+
alias_method :create?, :create
|
26
28
|
|
27
29
|
def exec_scripts?
|
28
30
|
!unit.post_start_scripts.empty? && exec_scripts
|
29
31
|
end
|
30
32
|
|
31
33
|
def create!
|
32
|
-
return nil
|
34
|
+
return nil unless create?
|
33
35
|
Create.new(unit, cmd: cmd).execute!
|
34
36
|
end
|
35
37
|
|
36
38
|
def start!
|
37
|
-
return nil if
|
38
|
-
|
39
|
-
|
39
|
+
return nil if unit_running?
|
40
|
+
if needed_unit_names_not_running.empty?
|
41
|
+
$logger.info "Starting '#{unit.display_name}' unit"
|
42
|
+
unit.container.start!
|
43
|
+
else
|
44
|
+
$logger.error "Cannot start '%s' unit, %s not running" %
|
45
|
+
[ unit.display_name, needed_unit_names_not_running ]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def unit_running?
|
50
|
+
!unit.startable? || unit.running?
|
51
|
+
end
|
52
|
+
|
53
|
+
def needed_unit_names_not_running
|
54
|
+
@needed_unit_names_not_running ||= begin
|
55
|
+
unit.startable_needed_units.each_with_object([]) do |unit_tuple, all|
|
56
|
+
_, unit = unit_tuple
|
57
|
+
all << unit.name unless unit.running?
|
58
|
+
end
|
59
|
+
end
|
40
60
|
end
|
41
61
|
|
42
62
|
def execute_post_start_scripts!
|
data/lib/percheron/unit.rb
CHANGED
@@ -8,8 +8,8 @@ module Percheron
|
|
8
8
|
include Unit::ImageHelper
|
9
9
|
|
10
10
|
def_delegators :unit_config, :name, :pseudo_name, :docker_image
|
11
|
-
def_config_item_with_default :unit_config, [], :env, :ports, :volumes, :
|
12
|
-
:
|
11
|
+
def_config_item_with_default :unit_config, [], :env, :ports, :volumes, :pre_build_scripts,
|
12
|
+
:post_start_scripts, :start_args, :dns
|
13
13
|
def_config_item_with_default :unit_config, true, :startable
|
14
14
|
|
15
15
|
def initialize(config, stack, unit_name)
|
@@ -20,6 +20,10 @@ module Percheron
|
|
20
20
|
self
|
21
21
|
end
|
22
22
|
|
23
|
+
def needed_unit_names
|
24
|
+
unit_config.fetch('needed_unit_names', unit_config.fetch('dependant_unit_names', []))
|
25
|
+
end
|
26
|
+
|
23
27
|
def needed_units
|
24
28
|
needed_unit_names.each_with_object({}) do |unit_name, all|
|
25
29
|
all[unit_name] = stack.units[unit_name]
|
data/lib/percheron/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: percheron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ash McKenzie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: clamp
|