raystool 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -27,9 +27,29 @@ require 'rays/interface/controller'
27
27
  class RaysCommand < Clamp::Command
28
28
  option '--silent', :flag, 'no output information'
29
29
  option '--debug', :flag, 'debug information'
30
+ option %w(-v --version), :flag, 'version'
30
31
 
31
32
  usage '[option] command [sub-command] [command option]'
32
33
 
34
+ def parse(arguments)
35
+ begin
36
+ super
37
+ show_version
38
+ rescue => e
39
+ show_version
40
+ raise e
41
+ end
42
+ end
43
+
44
+ def execute
45
+ if debug?
46
+ $log.debug_on
47
+ elsif silent?
48
+ $log.silent_on
49
+ end
50
+ super
51
+ end
52
+
33
53
  #
34
54
  # CREATE A NEW PROJECT
35
55
  #
@@ -37,7 +57,6 @@ class RaysCommand < Clamp::Command
37
57
  parameter 'project_name', 'project name'
38
58
 
39
59
  def execute
40
- process_global_options
41
60
  Rays::Controller.instance.create_project project_name
42
61
  end
43
62
  end
@@ -47,7 +66,6 @@ class RaysCommand < Clamp::Command
47
66
  #
48
67
  subcommand 'init', 'init a project on the current directory' do
49
68
  def execute
50
- process_global_options
51
69
  Rays::Controller.instance.init_project
52
70
  end
53
71
  end
@@ -58,7 +76,6 @@ class RaysCommand < Clamp::Command
58
76
  #
59
77
  subcommand 'modules', 'show all modules' do
60
78
  def execute
61
- process_global_options
62
79
  Rays::Controller.instance.show_modules
63
80
  end
64
81
  end
@@ -74,7 +91,6 @@ class RaysCommand < Clamp::Command
74
91
  option '--generator', 'GENERATOR', 'Generator name, maven by default'
75
92
 
76
93
  def execute
77
- process_global_options
78
94
  Rays::Controller.instance.create_module 'portlet', name, generator
79
95
  end
80
96
  end
@@ -84,7 +100,6 @@ class RaysCommand < Clamp::Command
84
100
  option '--generator', 'GENERATOR', 'Generator name, maven by default'
85
101
 
86
102
  def execute
87
- process_global_options
88
103
  Rays::Controller.instance.create_module 'servicebuilder', name, generator
89
104
  end
90
105
  end
@@ -94,7 +109,6 @@ class RaysCommand < Clamp::Command
94
109
  option '--generator', 'GENERATOR', 'Generator name, maven by default'
95
110
 
96
111
  def execute
97
- process_global_options
98
112
  Rays::Controller.instance.create_module 'ext', name, generator
99
113
  end
100
114
  end
@@ -104,7 +118,6 @@ class RaysCommand < Clamp::Command
104
118
  option '--generator', 'GENERATOR', 'Generator name, maven by default'
105
119
 
106
120
  def execute
107
- process_global_options
108
121
  Rays::Controller.instance.create_module 'hook', name, generator
109
122
  end
110
123
  end
@@ -114,7 +127,6 @@ class RaysCommand < Clamp::Command
114
127
  option '--generator', 'GENERATOR', 'Generator name, maven by default'
115
128
 
116
129
  def execute
117
- process_global_options
118
130
  Rays::Controller.instance.create_module 'theme', name, generator
119
131
  end
120
132
  end
@@ -124,7 +136,6 @@ class RaysCommand < Clamp::Command
124
136
  option '--generator', 'GENERATOR', 'Generator name, maven by default'
125
137
 
126
138
  def execute
127
- process_global_options
128
139
  Rays::Controller.instance.create_module 'layout', name, generator
129
140
  end
130
141
  end
@@ -139,7 +150,6 @@ class RaysCommand < Clamp::Command
139
150
  option '--skip-test', :flag, 'use this option if you want to skip module tests'
140
151
 
141
152
  def execute
142
- process_global_options
143
153
  modules = []
144
154
  if type.nil? and !name.nil?
145
155
  raise RaysException.new("Cannot build type w/o name.")
@@ -171,7 +181,6 @@ class RaysCommand < Clamp::Command
171
181
  option '--skip-test', :flag, 'use this option if you want to skip module tests'
172
182
 
173
183
  def execute
174
- process_global_options
175
184
  modules = []
176
185
  if type.nil? and !name.nil?
177
186
  raise RaysException.new("Cannot build type w/o name.")
@@ -202,7 +211,6 @@ class RaysCommand < Clamp::Command
202
211
  parameter '[name]', 'a module name'
203
212
 
204
213
  def execute
205
- process_global_options
206
214
  modules = []
207
215
  if type.nil? and !name.nil?
208
216
  raise RaysException.new("Cannot build type w/o name.")
@@ -233,7 +241,6 @@ class RaysCommand < Clamp::Command
233
241
  option '--list', :flag, 'list environments'
234
242
 
235
243
  def execute
236
- process_global_options
237
244
 
238
245
  if list?
239
246
  Rays::Controller.instance.list_environments
@@ -262,7 +269,6 @@ class RaysCommand < Clamp::Command
262
269
  option '--remove', :flag, 'remove a point. if no name is specified the point will be considered as default.'
263
270
 
264
271
  def execute
265
- process_global_options
266
272
  if remove?
267
273
  Rays::Controller.instance.remove_point name
268
274
  else
@@ -273,7 +279,6 @@ class RaysCommand < Clamp::Command
273
279
 
274
280
  subcommand 'points', 'show all points' do
275
281
  def execute
276
- process_global_options
277
282
  Rays::Controller.instance.points
278
283
  end
279
284
  end
@@ -283,7 +288,6 @@ class RaysCommand < Clamp::Command
283
288
  parameter '[name]', 'point name. if no name is specified the point will be considered as default.'
284
289
 
285
290
  def execute
286
- process_global_options
287
291
  Rays::Controller.instance.go name
288
292
  end
289
293
  end
@@ -293,7 +297,6 @@ class RaysCommand < Clamp::Command
293
297
  #
294
298
  subcommand 'backup', 'backup current environment' do
295
299
  def execute
296
- process_global_options
297
300
  Rays::Controller.instance.backup
298
301
  end
299
302
  end
@@ -303,7 +306,6 @@ class RaysCommand < Clamp::Command
303
306
  #
304
307
  subcommand 'sync', 'synchronize local environment with the current one' do
305
308
  def execute
306
- process_global_options
307
309
  Rays::Controller.instance.sync
308
310
  end
309
311
  end
@@ -317,7 +319,6 @@ class RaysCommand < Clamp::Command
317
319
  option '--force', :flag, 'use it only to [start | stop] remote servers. be careful!'
318
320
 
319
321
  def execute
320
- process_global_options
321
322
  if action.eql? 'start'
322
323
  Rays::Controller.instance.liferay_start(force?)
323
324
  elsif action.eql? 'debug'
@@ -344,7 +345,6 @@ class RaysCommand < Clamp::Command
344
345
  subcommand 'solr', 'manage solr server of the current environment' do
345
346
  subcommand 'clean', 'delete all records from the solr index' do
346
347
  def execute
347
- process_global_options
348
348
  Rays::Controller.instance.clean_solr_index
349
349
  end
350
350
  end
@@ -353,7 +353,6 @@ class RaysCommand < Clamp::Command
353
353
  option '--force', :flag, 'use it only to start a remote server. be careful!'
354
354
 
355
355
  def execute
356
- process_global_options
357
356
  Rays::Controller.instance.solr_start(force?)
358
357
  end
359
358
  end
@@ -362,37 +361,29 @@ class RaysCommand < Clamp::Command
362
361
  option '--force', :flag, 'use it only to stop a remote server. be careful!'
363
362
 
364
363
  def execute
365
- process_global_options
366
364
  Rays::Controller.instance.solr_stop(force?)
367
365
  end
368
366
  end
369
367
 
370
368
  subcommand 'log', 'show solr server log' do
371
369
  def execute
372
- process_global_options
373
370
  Rays::Controller.instance.solr_log
374
371
  end
375
372
  end
376
373
 
377
374
  subcommand 'status', 'show solr server status' do
378
375
  def execute
379
- process_global_options
380
376
  Rays::Controller.instance.solr_status
381
377
  end
382
378
  end
383
379
  end
384
380
 
385
-
386
381
  private
387
382
 
388
- #
389
- # OPTIONS PROCESSOR
390
- #
391
- def process_global_options
392
- if debug?
393
- $log.debug_on
394
- elsif silent?
395
- $log.silent_on
383
+ def show_version
384
+ if version?
385
+ $log.info Gem.loaded_specs['raystool'].version
386
+ exit 0
396
387
  end
397
388
  end
398
389
  end
@@ -78,11 +78,18 @@ module Rays
78
78
 
79
79
  # Stop service
80
80
  def stop
81
- if alive?
82
- execute @stop_script
83
- else
84
- raise RaysException.new('service is not running')
81
+ raise RaysException.new('service is not running') if not alive?
82
+
83
+ execute @stop_script
84
+ 10.times do
85
+ break if not alive?
86
+ sleep(1)
85
87
  end
88
+
89
+ if alive?
90
+ rays_exec("kill -9 `lsof -t -i tcp:#{@port}`")
91
+ sleep(2)
92
+ end
86
93
  end
87
94
 
88
95
  # normal restart
@@ -139,23 +146,13 @@ module Rays
139
146
  if alive?
140
147
  stop
141
148
  end
142
- started = false
143
- tries_limit = 30
144
- try = 0
145
- while try < tries_limit do
146
- unless alive?
147
- yield
148
- started = true
149
- break
150
- end
151
- try += 1
152
- sleep(1)
153
- end
154
149
 
155
- unless started
150
+ if alive?
156
151
  raise RaysException.new('service is stopping too long.')
157
152
  end
153
+
154
+ yield
158
155
  end
159
156
  end
160
157
  end
161
- end
158
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raystool
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-12 00:00:00.000000000 Z
12
+ date: 2012-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: clamp
16
- requirement: &78039190 !ruby/object:Gem::Requirement
16
+ requirement: &75825080 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *78039190
24
+ version_requirements: *75825080
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rsolr
27
- requirement: &78038700 !ruby/object:Gem::Requirement
27
+ requirement: &75824300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *78038700
35
+ version_requirements: *75824300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: colorize
38
- requirement: &78038370 !ruby/object:Gem::Requirement
38
+ requirement: &75824060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *78038370
46
+ version_requirements: *75824060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: net-ssh
49
- requirement: &78037960 !ruby/object:Gem::Requirement
49
+ requirement: &75823740 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *78037960
57
+ version_requirements: *75823740
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: highline
60
- requirement: &78037320 !ruby/object:Gem::Requirement
60
+ requirement: &75823320 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *78037320
68
+ version_requirements: *75823320
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: safe_shell
71
- requirement: &78036340 !ruby/object:Gem::Requirement
71
+ requirement: &75822920 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *78036340
79
+ version_requirements: *75822920
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: nokogiri
82
- requirement: &78035560 !ruby/object:Gem::Requirement
82
+ requirement: &75822570 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :runtime
89
89
  prerelease: false
90
- version_requirements: *78035560
90
+ version_requirements: *75822570
91
91
  description: Command line tool to create and manage liferay projects
92
92
  email: dmitri.carpov@gmail.com
93
93
  executables: