small-ops 0.0.5 → 0.0.6
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.
- data/bin/fige +20 -1
- data/lib/small-setup.rb +4 -0
- metadata +1 -1
data/bin/fige
CHANGED
|
@@ -13,12 +13,28 @@ env = {
|
|
|
13
13
|
|
|
14
14
|
@containers=[]
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
apps=[]
|
|
17
|
+
if @target then
|
|
18
|
+
apps=yml.keys.select {|k| k == @target}
|
|
19
|
+
else
|
|
20
|
+
apps=yml.keys
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
apps.each {|k|
|
|
17
24
|
|
|
18
25
|
if !yml[k].has_key? "name" then
|
|
19
26
|
yml[k]['name'] = yml[k]['image'].gsub(/[^\/]+\//,'')
|
|
20
27
|
end
|
|
21
28
|
|
|
29
|
+
json = `docker inspect #{yml[k]['name']}`
|
|
30
|
+
inspect = JSON.parse(json)
|
|
31
|
+
if inspect && inspect[0] && inspect[0]['State']
|
|
32
|
+
if inspect[0]["State"]['Running'] then
|
|
33
|
+
puts `docker stop #{inspect[0]["ID"]}`
|
|
34
|
+
end
|
|
35
|
+
puts `docker rm #{inspect[0]["ID"]}`
|
|
36
|
+
end
|
|
37
|
+
|
|
22
38
|
if !yml[k].has_key? "environment" then
|
|
23
39
|
yml[k]['environment'] = {}
|
|
24
40
|
end
|
|
@@ -64,6 +80,8 @@ yml.keys.each {|k|
|
|
|
64
80
|
cmd << " #{yml[k]["command"]} "
|
|
65
81
|
end
|
|
66
82
|
|
|
83
|
+
#`docker pull #{yml[k]['image']}`
|
|
84
|
+
|
|
67
85
|
cid = `#{cmd}`
|
|
68
86
|
@containers.push(cid)
|
|
69
87
|
puts "#{yml[k]['name']} = #{cid}"
|
|
@@ -74,6 +92,7 @@ puts `docker ps`
|
|
|
74
92
|
|
|
75
93
|
if @foreground then
|
|
76
94
|
def stop()
|
|
95
|
+
puts "Stopping..."
|
|
77
96
|
@containers.each {|cid|
|
|
78
97
|
puts `docker stop #{cid}`
|
|
79
98
|
puts `docker rm #{cid}`
|
data/lib/small-setup.rb
CHANGED
|
@@ -29,6 +29,9 @@ OptionParser.new do |opts|
|
|
|
29
29
|
opts.on("-c","--command cmd","A command to execute at certain point") do |c|
|
|
30
30
|
options[:cmd]=c
|
|
31
31
|
end
|
|
32
|
+
opts.on("-t","--target name","Target a single container") do |t|
|
|
33
|
+
options[:target]=t
|
|
34
|
+
end
|
|
32
35
|
end.parse!
|
|
33
36
|
|
|
34
37
|
|
|
@@ -39,6 +42,7 @@ end.parse!
|
|
|
39
42
|
@output = options[:output] || false
|
|
40
43
|
@input = options[:input] || false
|
|
41
44
|
@cmd = options[:cmd] || false
|
|
45
|
+
@target = options[:target] || false
|
|
42
46
|
|
|
43
47
|
def http_get(uri)
|
|
44
48
|
JSON.parse(Net::HTTP.get(URI(uri)))
|