gv-valley 0.0.2 → 0.0.3

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: a97752148a0e7d5ec68aaef6196d725f89cedd69
4
- data.tar.gz: 693a4034c1f4da6f53e88f4a6354ba9cc472f5d0
3
+ metadata.gz: 7f0c6b2b1055b28c5a27bf64bb68e146b5dfd3b9
4
+ data.tar.gz: 6cfac4214935634628a53a1578de31acab5376a3
5
5
  SHA512:
6
- metadata.gz: e55514e555542c05c559b6a861f439b9830488742f5cad85e8d3a1429a997fdd38dea24c9bbe6aae309365eb9211be56322734f075eab8882e303a556311df4b
7
- data.tar.gz: 70bda547d563f5d0714c82d60f16e291f06f449d58a3af36b1d14bf80b2fcf209daeed1c9c2f8a8e251f8229c1008e8b5e74032572641c156481c25462e11043
6
+ metadata.gz: fcf8de1fe095ad062872a637a71f5a2f30b27c82c7d2143296a8b637746789f2caaf2a26427525250fcc3f45be015232ff373e959c12dbdae1e472f396402a0b
7
+ data.tar.gz: ef25b695f731ce1e841da5edf251ff0335101c557c4585b4815c6ebf31f2371cfe63a5f55dfc592e047bb3ed33a4cbb1a5c94a7f740905faaf8b2cff4c551d11
data/bin/valley CHANGED
@@ -26,36 +26,39 @@ end
26
26
  # Apps API
27
27
 
28
28
  command :'apps:deploy' do |c|
29
- c.syntax = 'valley apps:deploy APP_NAME'
29
+ c.syntax = 'valley apps:deploy'
30
30
  c.description = 'deploys app'
31
+ c.option '--app STRING', String, 'App name'
31
32
  c.action do |args, options|
32
33
 
33
34
  DRb.start_service
34
35
  service = GV::Valley::Deployer.random_service
35
- service.deploy args.first, &Sticks::Pipe::Blocks.stream
36
+ service.deploy options.app, &Sticks::Pipe::Blocks.stream
36
37
  DRb.stop_service
37
38
  end
38
39
  end
39
40
 
40
41
  command :'apps:config' do |c|
41
- c.syntax = 'valley apps:config APP_NAME'
42
+ c.syntax = 'valley apps:config'
42
43
  c.description = 'shows app config'
44
+ c.option '--app STRING', String, 'App name'
43
45
  c.action do |args, options|
44
46
 
45
47
  DRb.start_service
46
- puts GV::Valley::App.find!(args.first)['config']
48
+ puts GV::Valley::App.find!(options.app)['config']
47
49
  DRb.stop_service
48
50
  end
49
51
  end
50
52
 
51
53
  command :'apps:config add' do |c|
52
- c.syntax = 'valley apps:config add APP_NAME KEY=VALUE [KEY=VALUE]'
54
+ c.syntax = 'valley apps:config add KEY=VALUE [KEY=VALUE]'
53
55
  c.description = 'adds item to app config'
56
+ c.option '--app STRING', String, 'App name'
54
57
  c.action do |args, options|
55
58
 
56
59
  DRb.start_service
57
60
 
58
- name = args.shift
61
+ name = options.app
59
62
  config = Hash[args.map{|kv| kv.split("=")}]
60
63
  app = GV::Valley::App.find!(name)
61
64
  app["config"].update(config)
@@ -68,13 +71,14 @@ command :'apps:config add' do |c|
68
71
  end
69
72
 
70
73
  command :'apps:config remove' do |c|
71
- c.syntax = 'valley apps:config remove APP_NAME KEY [KEY]'
74
+ c.syntax = 'valley apps:config remove KEY [KEY]'
72
75
  c.description = 'removes item from app config'
76
+ c.option '--app STRING', String, 'App name'
73
77
  c.action do |args, options|
74
78
 
75
79
  DRb.start_service
76
80
 
77
- name = args.shift
81
+ name = options.app
78
82
  app = GV::Valley::App.find!(name)
79
83
  args.each do |key|
80
84
  app["config"].delete(key)
@@ -88,24 +92,26 @@ command :'apps:config remove' do |c|
88
92
  end
89
93
 
90
94
  command :'apps:ps' do |c|
91
- c.syntax = 'valley apps:ps APP_NAME'
95
+ c.syntax = 'valley apps:ps'
92
96
  c.description = 'shows app processes'
97
+ c.option '--app STRING', String, 'App name'
93
98
  c.action do |args, options|
94
99
 
95
100
  DRb.start_service
96
- puts GV::Valley::App.find!(args.first)['ps'].map{|type,ps| {type => ps['scale']} }
101
+ puts GV::Valley::App.find!(options.app)['ps'].map{|type,ps| {type => ps['scale']} }
97
102
  DRb.stop_service
98
103
  end
99
104
  end
100
105
 
101
106
  command :'apps:ps scale' do |c|
102
- c.syntax = 'valley apps:ps scale APP_NAME TYPE=SCALE [TYPE=SCALE]'
107
+ c.syntax = 'valley apps:ps scale TYPE=SCALE [TYPE=SCALE]'
103
108
  c.description = 'shows app processes'
109
+ c.option '--app STRING', String, 'App name'
104
110
  c.action do |args, options|
105
111
 
106
112
  DRb.start_service
107
113
 
108
- name = args.shift
114
+ name = options.app
109
115
  ps = Hash[args.map{|kv| kv.split("=")}]
110
116
  app = GV::Valley::App.find!(name)
111
117
  ps.each do |key,scale|
@@ -123,24 +129,26 @@ command :'apps:ps scale' do |c|
123
129
  end
124
130
 
125
131
  command :'apps:domains' do |c|
126
- c.syntax = 'valley apps:domains APP_NAME'
132
+ c.syntax = 'valley apps:domains'
127
133
  c.description = 'shows app domains'
134
+ c.option '--app STRING', String, 'App name'
128
135
  c.action do |args, options|
129
136
 
130
137
  DRb.start_service
131
- puts GV::Valley::App.find!(args.first)['domains']
138
+ puts GV::Valley::App.find!(options.app)['domains']
132
139
  DRb.stop_service
133
140
  end
134
141
  end
135
142
 
136
143
  command :'apps:domains add' do |c|
137
- c.syntax = 'valley apps:domains add APP_NAME DOMAIN [DOMAIN]'
144
+ c.syntax = 'valley apps:domains add DOMAIN [DOMAIN]'
138
145
  c.description = 'adds item to app domains'
146
+ c.option '--app STRING', String, 'App name'
139
147
  c.action do |args, options|
140
148
 
141
149
  DRb.start_service
142
150
 
143
- name = args.shift
151
+ name = options.app
144
152
  app = GV::Valley::App.find!(name)
145
153
  domains = args - GV::Valley::App.all.map{|a| a["domains"]}.flatten
146
154
  app["domains"] = (app["domains"] + domains).compact.uniq
@@ -153,13 +161,14 @@ command :'apps:domains add' do |c|
153
161
  end
154
162
 
155
163
  command :'apps:domains remove' do |c|
156
- c.syntax = 'valley apps:domains remove APP_NAME DOMAIN [DOMAIN]'
164
+ c.syntax = 'valley apps:domains remove DOMAIN [DOMAIN]'
157
165
  c.description = 'removes item from app domains'
166
+ c.option '--app STRING', String, 'App name'
158
167
  c.action do |args, options|
159
168
 
160
169
  DRb.start_service
161
170
 
162
- name = args.shift
171
+ name = options.app
163
172
  app = GV::Valley::App.find!(name)
164
173
  app["domains"] = app["domains"] - args
165
174
  app.save
@@ -171,13 +180,14 @@ command :'apps:domains remove' do |c|
171
180
  end
172
181
 
173
182
  command :'apps:run' do |c|
174
- c.syntax = 'valley apps:run APP_NAME CMD'
183
+ c.syntax = 'valley apps:run CMD'
175
184
  c.description = 'runs cmd on app'
185
+ c.option '--app STRING', String, 'App name'
176
186
  c.action do |args, options|
177
187
 
178
188
  DRb.start_service
179
189
  service = GV::Valley::Runner.random_service
180
- name = args.shift
190
+ name = options.app
181
191
  cmd = args.join(" ")
182
192
  block = cmd =~ Sticks::Pipe::INTERACTIVE_COMMANDS ? Sticks::Pipe::Blocks.interactive : Sticks::Pipe::Blocks.stream
183
193
  service.run name, cmd, &block
@@ -186,13 +196,14 @@ command :'apps:run' do |c|
186
196
  end
187
197
 
188
198
  command :'apps:logs' do |c|
189
- c.syntax = 'valley apps:logs APP_NAME <PS>'
199
+ c.syntax = 'valley apps:logs <PS>'
190
200
  c.description = 'runs cmd on app'
201
+ c.option '--app STRING', String, 'App name'
191
202
  c.option '-f','--follow', String, 'streams log'
192
203
  c.action do |args, options|
193
204
 
194
205
  DRb.start_service
195
- name = args.shift
206
+ name = options.app
196
207
  app = GV::Valley::App.find!(name)
197
208
  ps = args.shift
198
209
  psname = "#{name}.#{ps}"
@@ -209,38 +220,39 @@ command :'apps:logs' do |c|
209
220
  end
210
221
  end
211
222
 
212
- command :'apps:logs' do |c|
213
- c.syntax = 'valley apps:logs APP_NAME <PS>'
214
- c.description = 'runs cmd on app'
215
- c.option '-f','--follow', String, 'streams log'
216
- c.action do |args, options|
217
-
218
- DRb.start_service
219
- name = args.shift
220
- app = GV::Valley::App.find!(name)
221
- ps = args.shift
222
- psname = "#{name}.#{ps}"
223
-
224
- # debug GV::Valley::Deployer.space.read_all([:ps,/#{psname}/,nil,nil])
225
-
226
- tuple = [:ps, /#{psname}/, nil, nil ]
227
- block = options.follow ? Sticks::Pipe::Blocks.stream : Sticks::Pipe::Blocks.capture
228
- (GV::Valley::Deployer.space.read_all(tuple) rescue []).each do |h|
229
- h[2].logs psname,options.follow, &block
230
- end
231
-
232
- DRb.stop_service
233
- end
234
- end
223
+ # command :'apps:logs' do |c|
224
+ # c.syntax = 'valley apps:logs APP_NAME <PS>'
225
+ # c.description = 'runs cmd on app'
226
+ # c.option '-f','--follow', String, 'streams log'
227
+ # c.action do |args, options|
228
+ #
229
+ # DRb.start_service
230
+ # name = args.shift
231
+ # app = GV::Valley::App.find!(name)
232
+ # ps = args.shift
233
+ # psname = "#{name}.#{ps}"
234
+ #
235
+ # # debug GV::Valley::Deployer.space.read_all([:ps,/#{psname}/,nil,nil])
236
+ #
237
+ # tuple = [:ps, /#{psname}/, nil, nil ]
238
+ # block = options.follow ? Sticks::Pipe::Blocks.stream : Sticks::Pipe::Blocks.capture
239
+ # (GV::Valley::Deployer.space.read_all(tuple) rescue []).each do |h|
240
+ # h[2].logs psname,options.follow, &block
241
+ # end
242
+ #
243
+ # DRb.stop_service
244
+ # end
245
+ # end
235
246
 
236
247
  command :'apps:destroy' do |c|
237
- c.syntax = 'valley apps:destroy APP_NAME'
248
+ c.syntax = 'valley apps:destroy'
238
249
  c.description = 'destroys app'
250
+ c.option '--app STRING', String, 'App name'
239
251
  c.action do |args, options|
240
252
 
241
253
  DRb.start_service
242
254
 
243
- name = args.shift
255
+ name = options.app
244
256
  app = GV::Valley::App.find!(name)
245
257
 
246
258
  deployer = GV::Valley::Deployer.service
@@ -267,13 +279,14 @@ command :'balancer:reload' do |c|
267
279
  end
268
280
 
269
281
  command :'addons:create' do |c|
270
- c.syntax = 'valley addons:create NAME APP_NAME'
282
+ c.syntax = 'valley addons:create NAME'
271
283
  c.description = 'creates addon service'
284
+ c.option '--app STRING', String, 'App name'
272
285
  c.action do |args, options|
273
286
 
274
287
  DRb.start_service
275
288
  addon = args.shift
276
- app_name = args.shift
289
+ app_name = options.app
277
290
 
278
291
  require "gv/addons/#{addon}"
279
292
  addon_service = "GV::Addons::#{addon.classify}".constantize.service
@@ -284,13 +297,14 @@ command :'addons:create' do |c|
284
297
  end
285
298
 
286
299
  command :'addons:run' do |c|
287
- c.syntax = 'valley addons:run NAME APP_NAME CMD'
300
+ c.syntax = 'valley addons:run NAME CMD'
288
301
  c.description = 'runs method on addon service'
302
+ c.option '--app STRING', String, 'App name'
289
303
  c.action do |args, options|
290
304
 
291
305
  DRb.start_service
292
306
  addon = args.shift
293
- app_name = args.shift
307
+ app_name = options.app
294
308
  cmd = args.shift
295
309
 
296
310
  require "gv/addons/#{addon}"
@@ -302,13 +316,14 @@ command :'addons:run' do |c|
302
316
  end
303
317
 
304
318
  command :'addons:destroy' do |c|
305
- c.syntax = 'valley addons:destroy NAME APP_NAME'
319
+ c.syntax = 'valley addons:destroy NAME'
306
320
  c.description = 'destroys addon service'
321
+ c.option '--app STRING', String, 'App name'
307
322
  c.action do |args, options|
308
323
 
309
324
  DRb.start_service
310
325
  addon = args.shift
311
- app_name = args.shift
326
+ app_name = options.app
312
327
 
313
328
  require "gv/addons/#{addon}"
314
329
  addon_service = "GV::Addons::#{addon.classify}".constantize.service
data/gv-valley.gemspec CHANGED
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_dependency 'goliath'
24
24
  spec.add_dependency 'etcd'
25
25
  spec.add_dependency 'gv-common'
26
- spec.add_dependency 'gv-bedrock'
26
+ spec.add_dependency 'gv-bedrock', '~> 0.0.2'
27
27
  end
data/lib/gv/valley/app.rb CHANGED
@@ -61,7 +61,8 @@ module GV
61
61
  def default_config name
62
62
  config = {
63
63
  "SLUG_URL" => "#{GV::Valley::FileServer.service.url}/#{name}/slug.tgz",
64
- "PORT" => PORT
64
+ "PORT" => PORT,
65
+ "RACK_ENV" => "production"
65
66
  }
66
67
  end
67
68
 
@@ -31,9 +31,12 @@ module GV
31
31
  end
32
32
 
33
33
  backend << "backend b_#{app["name"]}\n"
34
- app["ps"]["web"]["containers"].each do |container|
35
- host = container['HostConfig']['PortBindings']["#{App::PORT}/tcp"].first
36
- backend << "#{INDENT}server srv_#{container['ID'][0..6]} #{host['HostIp']}:#{host['HostPort']}\n"
34
+ app["ps"].select{|k,v| k =~ /web/}.each do |ps,pdata|
35
+ pdata['containers'].each do |container|
36
+ # app["ps"]["web"]["containers"].each do |container|
37
+ host = container['HostConfig']['PortBindings']["#{App::PORT}/tcp"].first
38
+ backend << "#{INDENT}server srv_#{container['ID'][0..6]} #{host['HostIp']}:#{host['HostPort']}\n"
39
+ end
37
40
  end
38
41
 
39
42
  end
@@ -103,7 +103,7 @@ module GV
103
103
  runner.run
104
104
  at_exit {
105
105
  pid = File.read("/var/run/gv-file_server.pid").chomp.to_i
106
- Process.kill("TERM",pid)
106
+ Process.kill("TERM",pid) rescue nil
107
107
  File.delete("/var/run/gv-file_server.pid")
108
108
  File.delete("/var/log/gv-file_server.log")
109
109
  File.delete("/var/log/gv-file_server.log_stdout.log")
@@ -1,5 +1,5 @@
1
1
  module GV
2
2
  module Valley
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
data/test/gv/test_app.rb CHANGED
@@ -46,7 +46,7 @@ module GV
46
46
 
47
47
  # clear all services
48
48
  GV::Bedrock::Service.space.read_all([nil,nil,nil,nil]).each do |t|
49
- GV::Bedrock::Service.space.take(t)
49
+ GV::Bedrock::Service.space.take(t,0) rescue nil
50
50
  end
51
51
 
52
52
  DRb.stop_service
data/test/gv/test_etcd.rb CHANGED
@@ -24,7 +24,7 @@ module GV
24
24
 
25
25
  # clear all services
26
26
  GV::Bedrock::Service.space.read_all([nil,nil,nil,nil]).each do |t|
27
- GV::Bedrock::Service.space.take(t)
27
+ GV::Bedrock::Service.space.take(t,0) rescue nil
28
28
  end
29
29
 
30
30
  DRb.stop_service
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gv-valley
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Onur Uyar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-22 00:00:00.000000000 Z
11
+ date: 2014-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,16 +98,16 @@ dependencies:
98
98
  name: gv-bedrock
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.0.2
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ~>
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.0.2
111
111
  description:
112
112
  email:
113
113
  - me@onuruyar.com