raystool 1.0.2
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/__rays_exec.rb +31 -0
- data/bin/__rays_init +79 -0
- data/lib/rays/config/backup.rb +42 -0
- data/lib/rays/config/configuration.rb +376 -0
- data/lib/rays/config/environment.rb +73 -0
- data/lib/rays/config/templates/global/global.yml +3 -0
- data/lib/rays/config/templates/global/scripts/rays +187 -0
- data/lib/rays/config/templates/project/.rays +0 -0
- data/lib/rays/config/templates/project/config/environment.yml +68 -0
- data/lib/rays/config/templates/project/config/project.yml +4 -0
- data/lib/rays/core.rb +128 -0
- data/lib/rays/exceptions/rays_exception.rb +25 -0
- data/lib/rays/interface/commander.rb +394 -0
- data/lib/rays/interface/controller.rb +365 -0
- data/lib/rays/loaders/highline.rb +24 -0
- data/lib/rays/loaders/logging.rb +60 -0
- data/lib/rays/models/appmodule/base.rb +185 -0
- data/lib/rays/models/appmodule/content.rb +35 -0
- data/lib/rays/models/appmodule/ext.rb +36 -0
- data/lib/rays/models/appmodule/hook.rb +36 -0
- data/lib/rays/models/appmodule/layout.rb +36 -0
- data/lib/rays/models/appmodule/manager.rb +130 -0
- data/lib/rays/models/appmodule/portlet.rb +36 -0
- data/lib/rays/models/appmodule/servicebuilder.rb +36 -0
- data/lib/rays/models/appmodule/theme.rb +36 -0
- data/lib/rays/models/project.rb +116 -0
- data/lib/rays/servers/base.rb +70 -0
- data/lib/rays/servers/database.rb +73 -0
- data/lib/rays/servers/liferay.rb +64 -0
- data/lib/rays/servers/solr.rb +111 -0
- data/lib/rays/services/application_service.rb +116 -0
- data/lib/rays/services/backup_service.rb +94 -0
- data/lib/rays/services/database.rb +59 -0
- data/lib/rays/services/remote.rb +75 -0
- data/lib/rays/services/scm.rb +92 -0
- data/lib/rays/services/sync.rb +90 -0
- data/lib/rays/utils/common_utils.rb +153 -0
- data/lib/rays/utils/file_utils.rb +118 -0
- data/lib/rays/utils/network_utils.rb +50 -0
- data/lib/rays/workers/base.rb +134 -0
- data/lib/rays/workers/builder.rb +63 -0
- data/lib/rays/workers/cleaner.rb +42 -0
- data/lib/rays/workers/deployer.rb +92 -0
- data/lib/rays/workers/generator.rb +49 -0
- metadata +175 -0
data/bin/__rays_exec.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
Copyright (c) 2012 Dmitri Carpov
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
|
26
|
+
require 'rays/interface/commander'
|
27
|
+
|
28
|
+
begin
|
29
|
+
RaysCommand.run('rays', ARGV, {})
|
30
|
+
rescue => e
|
31
|
+
end
|
data/bin/__rays_init
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
=begin
|
4
|
+
Copyright (c) 2012 Dmitri Carpov
|
5
|
+
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
a copy of this software and associated documentation files (the
|
8
|
+
"Software"), to deal in the Software without restriction, including
|
9
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
the following conditions:
|
13
|
+
|
14
|
+
The above copyright notice and this permission notice shall be
|
15
|
+
included in all copies or substantial portions of the Software.
|
16
|
+
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
=end
|
25
|
+
|
26
|
+
require 'colorize'
|
27
|
+
require 'fileutils'
|
28
|
+
require 'find'
|
29
|
+
|
30
|
+
registered = false
|
31
|
+
|
32
|
+
config_dir = '.rays_config'
|
33
|
+
config_path = "#{ENV['HOME']}/#{config_dir}"
|
34
|
+
script_file = "$HOME/#{config_dir}/scripts/rays"
|
35
|
+
script_file_full_path = "#{ENV['HOME']}/#{config_dir}/scripts/rays"
|
36
|
+
|
37
|
+
command = "\n[[ -s \"#{script_file}\" ]] && source \"#{script_file}\" # Load RAYS into a shell session *as a function*'\n\n"
|
38
|
+
|
39
|
+
profile_file = "#{ENV['HOME']}/.bashrc"
|
40
|
+
profile_file = "#{ENV['HOME']}/.bash_profile" unless File.exists?(profile_file)
|
41
|
+
profile_file = "#{ENV['HOME']}/.profile" unless File.exists?(profile_file)
|
42
|
+
|
43
|
+
unless File.exists?(profile_file)
|
44
|
+
puts "Cannot find profile file."
|
45
|
+
puts "Add the following command manually to the end of your profile file"
|
46
|
+
puts command
|
47
|
+
end
|
48
|
+
|
49
|
+
begin
|
50
|
+
registered = !open(profile_file).grep(/rays/).empty?
|
51
|
+
rescue => e
|
52
|
+
# do nothing
|
53
|
+
end
|
54
|
+
|
55
|
+
unless registered
|
56
|
+
|
57
|
+
# Create directory and copy template
|
58
|
+
unless Dir.exists?(config_path)
|
59
|
+
FileUtils.mkdir(config_path)
|
60
|
+
template_path = "#{File.expand_path(File.dirname(__FILE__))}/../lib/rays/config/templates/global"
|
61
|
+
Find.find(template_path) do |file|
|
62
|
+
file_base_path = file.sub(template_path, "")
|
63
|
+
next if file_base_path.empty?
|
64
|
+
FileUtils.cp_r(file, File.join(config_path, file_base_path))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
File.open(profile_file, 'a') do |file|
|
69
|
+
file.write(command)
|
70
|
+
end
|
71
|
+
|
72
|
+
else
|
73
|
+
# update script file.
|
74
|
+
if File.exist?(script_file_full_path)
|
75
|
+
FileUtils.cp("#{File.expand_path(File.dirname(__FILE__))}/../lib/rays/config/templates/global/scripts/rays", script_file_full_path)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
puts "Please run '. #{profile_file}' or reopen your shell window".yellow
|
@@ -0,0 +1,42 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2012 Dmitri Carpov
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
module Rays
|
25
|
+
class Backup
|
26
|
+
attr_reader :directory, :number_of_backups, :stop_server
|
27
|
+
|
28
|
+
def initialize(directory, number_of_backups, stop_server)
|
29
|
+
@directory = directory
|
30
|
+
@number_of_backups = number_of_backups # ignored for now
|
31
|
+
@stop_server = stop_server # if server should be stopped before backup
|
32
|
+
default
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
def default
|
37
|
+
@directory ||= '/tmp/rays_backup'
|
38
|
+
@number_of_backups = 1
|
39
|
+
@stop_server = false
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,376 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2012 Dmitri Carpov
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
module Rays
|
25
|
+
|
26
|
+
class Configuration
|
27
|
+
attr_reader :points
|
28
|
+
|
29
|
+
#
|
30
|
+
# Create Configuration object
|
31
|
+
#
|
32
|
+
def initialize
|
33
|
+
@debug = false
|
34
|
+
@silent = false
|
35
|
+
$global_config_path ||= "#{ENV['HOME']}/.rays_config"
|
36
|
+
@global_config_file = nil
|
37
|
+
load_config
|
38
|
+
end
|
39
|
+
|
40
|
+
#
|
41
|
+
# Get project root or throw an exception if invoked outside of a project
|
42
|
+
#
|
43
|
+
def project_root
|
44
|
+
raise RaysException.new("Cannot find project root.") if @project_root.nil? or @project_root.empty?
|
45
|
+
@project_root
|
46
|
+
end
|
47
|
+
|
48
|
+
#
|
49
|
+
# Get current environment
|
50
|
+
#
|
51
|
+
def environment
|
52
|
+
project_root # check if it's inside a project dir
|
53
|
+
raise RaysException.new("no environment is configured. see: config/environment.yml.") if @environment.nil?
|
54
|
+
@environment
|
55
|
+
end
|
56
|
+
|
57
|
+
#
|
58
|
+
# Set environment
|
59
|
+
#
|
60
|
+
def environment=(environment_name)
|
61
|
+
if environments.include?(environment_name)
|
62
|
+
yaml_file = get_dot_rays_file
|
63
|
+
yaml_file.properties['environment'] = environment_name
|
64
|
+
yaml_file.write
|
65
|
+
Core.instance.reload
|
66
|
+
else
|
67
|
+
raise RaysException.new("cannot find environment <!#{environment_name}!>")
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
#
|
72
|
+
# Get list of environments
|
73
|
+
#
|
74
|
+
def environments
|
75
|
+
project_root # check if it's inside a project dir
|
76
|
+
raise RaysException.new("no environment is configured. see: config/environment.yml.") if @environments.nil?
|
77
|
+
@environments
|
78
|
+
end
|
79
|
+
|
80
|
+
#
|
81
|
+
# Get secure copy command
|
82
|
+
#
|
83
|
+
def scp
|
84
|
+
save = false
|
85
|
+
begin
|
86
|
+
check_command(@scp, 'usage: scp')
|
87
|
+
rescue RaysException => e
|
88
|
+
save = true
|
89
|
+
$log.error(e)
|
90
|
+
@scp = $terminal.ask('please provide the path to scp executable: ')
|
91
|
+
retry
|
92
|
+
end
|
93
|
+
|
94
|
+
if save
|
95
|
+
get_global_config.properties['scp_cmd'] = @scp
|
96
|
+
get_global_config.write
|
97
|
+
end
|
98
|
+
|
99
|
+
@scp
|
100
|
+
end
|
101
|
+
|
102
|
+
#
|
103
|
+
# Get maven command
|
104
|
+
#
|
105
|
+
def mvn
|
106
|
+
save = false
|
107
|
+
begin
|
108
|
+
check_command(@mvn, 'Apache Maven', '-v')
|
109
|
+
rescue RaysException => e
|
110
|
+
save = true
|
111
|
+
$log.error(e)
|
112
|
+
@mvn = $terminal.ask('please provide the path to mvn executable: ')
|
113
|
+
retry
|
114
|
+
end
|
115
|
+
|
116
|
+
if save
|
117
|
+
get_global_config.properties['mvn_cmd'] = @mvn
|
118
|
+
get_global_config.write
|
119
|
+
end
|
120
|
+
|
121
|
+
@mvn
|
122
|
+
end
|
123
|
+
|
124
|
+
#
|
125
|
+
# Remember a point
|
126
|
+
#
|
127
|
+
def point(dir, name)
|
128
|
+
unless Dir.exist?(dir)
|
129
|
+
raise RaysException.new("Cannot remember a point to a directory which does not exist. directory: <!#{dir}!>")
|
130
|
+
end
|
131
|
+
|
132
|
+
global_config = get_global_config
|
133
|
+
global_config.properties['points'] = Hash.new if global_config.properties['points'].nil?
|
134
|
+
point_name = name
|
135
|
+
point_name ||= 'default'
|
136
|
+
global_config.properties['points'][point_name] = dir
|
137
|
+
global_config.write
|
138
|
+
end
|
139
|
+
|
140
|
+
#
|
141
|
+
# Remove a point
|
142
|
+
#
|
143
|
+
def remove_point(name)
|
144
|
+
global_config = get_global_config
|
145
|
+
global_config.properties['points'] = Hash.new if global_config.properties['points'].nil?
|
146
|
+
point_name = name
|
147
|
+
point_name ||= 'default'
|
148
|
+
|
149
|
+
if global_config.properties['points'].nil? or global_config.properties['points'][point_name].nil?
|
150
|
+
raise RaysException.new("#{name} point does not exist")
|
151
|
+
end
|
152
|
+
|
153
|
+
global_config.properties['points'].delete point_name
|
154
|
+
global_config.write
|
155
|
+
end
|
156
|
+
|
157
|
+
private
|
158
|
+
#
|
159
|
+
# Initializes environments and project parameters.
|
160
|
+
#
|
161
|
+
def load_config
|
162
|
+
log_block('process configuration file') do
|
163
|
+
init_global_config
|
164
|
+
init_project_root
|
165
|
+
return if @project_root.nil?
|
166
|
+
|
167
|
+
init_environments
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
#
|
172
|
+
# Logic for defining project's root.
|
173
|
+
# It looks for a directory which contains .rays file.
|
174
|
+
# Start looking from the current directory and up to the root.
|
175
|
+
#
|
176
|
+
def init_project_root
|
177
|
+
return unless @project_root.nil?
|
178
|
+
@project_root = Rays::Utils::FileUtils.find_up('.rays')
|
179
|
+
end
|
180
|
+
|
181
|
+
#
|
182
|
+
# Main initialization method.
|
183
|
+
# Load environments and set the first declared environment as default.
|
184
|
+
#
|
185
|
+
def init_environments
|
186
|
+
@environments = {}
|
187
|
+
environment_config_file = "#{@project_root}/config/environment.yml"
|
188
|
+
environment_config = YAML::load_file(environment_config_file)
|
189
|
+
|
190
|
+
|
191
|
+
environment_config.each_key do |code|
|
192
|
+
#
|
193
|
+
# liferay
|
194
|
+
#
|
195
|
+
liferay_server = nil
|
196
|
+
liferay_config = environment_config[code]['liferay']
|
197
|
+
unless liferay_config.nil?
|
198
|
+
host = liferay_config['host']
|
199
|
+
port = liferay_config['port']
|
200
|
+
deploy = liferay_config['deploy']
|
201
|
+
data_directory = liferay_config['data']
|
202
|
+
remote = create_remote_for liferay_config
|
203
|
+
java_home = nil
|
204
|
+
java_bin = nil
|
205
|
+
java_config = liferay_config['java']
|
206
|
+
unless java_config.nil?
|
207
|
+
java_home = java_config['home']
|
208
|
+
java_bin = java_config['bin']
|
209
|
+
end
|
210
|
+
application_service = create_application_service_for(code, liferay_config)
|
211
|
+
|
212
|
+
liferay_server = Server::LiferayServer.new 'liferay server', host, remote, java_home, java_bin, port, deploy, data_directory, application_service
|
213
|
+
end
|
214
|
+
|
215
|
+
#
|
216
|
+
# database
|
217
|
+
#
|
218
|
+
database_server = nil
|
219
|
+
database_config = environment_config[code]['database']
|
220
|
+
unless database_config.nil?
|
221
|
+
host = database_config['host']
|
222
|
+
port = database_config['port']
|
223
|
+
type = database_config['type']
|
224
|
+
db_name = database_config['name']
|
225
|
+
username = database_config['username']
|
226
|
+
password = database_config['password']
|
227
|
+
remote = create_remote_for database_config
|
228
|
+
java_home = nil
|
229
|
+
java_bin = nil
|
230
|
+
java_config = liferay_config['java']
|
231
|
+
unless java_config.nil?
|
232
|
+
java_home = java_config['home']
|
233
|
+
java_bin = java_config['bin']
|
234
|
+
end
|
235
|
+
database_server = Server::DatabaseServer.new 'database server', host, remote, java_home, java_bin, port, db_name, username, password, type
|
236
|
+
end
|
237
|
+
|
238
|
+
#
|
239
|
+
# solr
|
240
|
+
#
|
241
|
+
solr_server = nil
|
242
|
+
solr_config = environment_config[code]['solr']
|
243
|
+
unless solr_config.nil?
|
244
|
+
host = solr_config['host']
|
245
|
+
port = solr_config['port']
|
246
|
+
url = solr_config['url']
|
247
|
+
remote = create_remote_for solr_config
|
248
|
+
java_home = nil
|
249
|
+
java_bin = nil
|
250
|
+
java_config = liferay_config['java']
|
251
|
+
unless java_config.nil?
|
252
|
+
java_home = java_config['home']
|
253
|
+
java_bin = java_config['bin']
|
254
|
+
end
|
255
|
+
application_service = create_application_service_for(code, solr_config)
|
256
|
+
|
257
|
+
solr_server = Server::SolrServer.new 'solr server', host, remote, java_home, java_bin, port, url, application_service
|
258
|
+
end
|
259
|
+
|
260
|
+
#
|
261
|
+
# Backup
|
262
|
+
#
|
263
|
+
backup_config = nil
|
264
|
+
backup_config_map = environment_config[code]['backup']
|
265
|
+
unless backup_config_map.nil?
|
266
|
+
directory = backup_config_map['directory']
|
267
|
+
number_of_backups = backup_config_map['number_of_backups']
|
268
|
+
stop = backup_config_map['stop']
|
269
|
+
backup_config = Backup.new(directory, number_of_backups, stop)
|
270
|
+
else
|
271
|
+
backup_config = Backup.new(nil, nil, nil)
|
272
|
+
end
|
273
|
+
|
274
|
+
@environments[code] = Environment.new code, liferay_server, database_server, solr_server, backup_config
|
275
|
+
end
|
276
|
+
|
277
|
+
|
278
|
+
# load current environment
|
279
|
+
yaml_file = get_dot_rays_file
|
280
|
+
env = yaml_file.properties['environment']
|
281
|
+
if @environments.include?(env)
|
282
|
+
@environment = @environments[env]
|
283
|
+
end
|
284
|
+
@environment ||= @environments.values.first unless @environments.values.empty?
|
285
|
+
|
286
|
+
end
|
287
|
+
|
288
|
+
#
|
289
|
+
# Create application service for.
|
290
|
+
#
|
291
|
+
def create_application_service_for(code, config)
|
292
|
+
application_service = nil
|
293
|
+
application_service_config = config['service']
|
294
|
+
host = config['host']
|
295
|
+
port = config['port']
|
296
|
+
remote = create_remote_for config
|
297
|
+
unless application_service_config.nil?
|
298
|
+
path = application_service_config['path']
|
299
|
+
path = "" if path.nil?
|
300
|
+
start_script = File.join(path, application_service_config['start_command'])
|
301
|
+
debug_script = nil
|
302
|
+
unless application_service_config['debug_command'].nil?
|
303
|
+
debug_script = File.join(path, application_service_config['debug_command'])
|
304
|
+
end
|
305
|
+
stop_script = File.join(path, application_service_config['stop_command'])
|
306
|
+
log_file = File.join(path, application_service_config['log_file'])
|
307
|
+
|
308
|
+
application_remote = remote
|
309
|
+
if code == 'local' or host == 'localhost'
|
310
|
+
application_remote = nil
|
311
|
+
end
|
312
|
+
|
313
|
+
application_service = Service::ApplicationService.new 'liferay', host, port, start_script, debug_script, stop_script, log_file, application_remote
|
314
|
+
end
|
315
|
+
application_service
|
316
|
+
end
|
317
|
+
|
318
|
+
#
|
319
|
+
# Create an instance of a remote service using server configuration map.
|
320
|
+
#
|
321
|
+
def create_remote_for(config)
|
322
|
+
remote = nil
|
323
|
+
if !config.nil? and !config['ssh'].nil? and !config['ssh']['user'].nil?
|
324
|
+
host = config['host']
|
325
|
+
port = config['ssh']['port']
|
326
|
+
user = config['ssh']['user']
|
327
|
+
remote = Service::Remote::SSH.new host, port, user
|
328
|
+
end
|
329
|
+
remote
|
330
|
+
end
|
331
|
+
|
332
|
+
def get_dot_rays_file
|
333
|
+
dot_rays_file = File.join(project_root, '.rays')
|
334
|
+
Utils::FileUtils::YamlFile.new dot_rays_file
|
335
|
+
end
|
336
|
+
|
337
|
+
#
|
338
|
+
# GLOBAL CONFIGURATION PROCESSING
|
339
|
+
#
|
340
|
+
|
341
|
+
def init_global_config
|
342
|
+
@points = get_global_config.properties['points']
|
343
|
+
@mvn = get_global_config.properties['maven_cmd']
|
344
|
+
@scp = get_global_config.properties['scp_cmd']
|
345
|
+
end
|
346
|
+
|
347
|
+
def get_global_config
|
348
|
+
check_global_config
|
349
|
+
global_config_file = File.join($global_config_path, 'global.yml')
|
350
|
+
raise RaysException.new("Cannot load global config file from #{global_config_file}") unless File.exists?(global_config_file)
|
351
|
+
@global_config_file = Utils::FileUtils::YamlFile.new global_config_file if @global_config_file.nil?
|
352
|
+
@global_config_file
|
353
|
+
end
|
354
|
+
|
355
|
+
def check_global_config
|
356
|
+
unless Dir.exist?($global_config_path)
|
357
|
+
FileUtils.mkdir($global_config_path)
|
358
|
+
template_path = "#{File.expand_path(File.dirname(__FILE__))}/templates/global"
|
359
|
+
Find.find(template_path) do |file|
|
360
|
+
file_base_path = file.sub(template_path, "")
|
361
|
+
next if file_base_path.empty?
|
362
|
+
FileUtils.cp_r(file, File.join($global_config_path, file_base_path))
|
363
|
+
end
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
def check_command(command, validation_answer, *args)
|
368
|
+
raise RaysException.new("#{command}: command not found") unless command?(command)
|
369
|
+
unless rays_safe_exec(command, *args).include?(validation_answer)
|
370
|
+
raise RaysException.new("#{command}: has unexpected format")
|
371
|
+
end
|
372
|
+
true
|
373
|
+
end
|
374
|
+
|
375
|
+
end
|
376
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
=begin
|
2
|
+
Copyright (c) 2012 Dmitri Carpov
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
=end
|
23
|
+
|
24
|
+
module Rays
|
25
|
+
class Environment
|
26
|
+
|
27
|
+
attr_reader :name
|
28
|
+
|
29
|
+
def initialize(name, liferay, database, solr, backup)
|
30
|
+
@name = name
|
31
|
+
@liferay = liferay
|
32
|
+
@database = database
|
33
|
+
@solr = solr
|
34
|
+
@backup = backup
|
35
|
+
end
|
36
|
+
|
37
|
+
def liferay
|
38
|
+
raise RaysException.new('Liferay is not enabled for this project') if @liferay.nil?
|
39
|
+
@liferay
|
40
|
+
end
|
41
|
+
|
42
|
+
def liferay_enabled?
|
43
|
+
@liferay.nil?
|
44
|
+
end
|
45
|
+
|
46
|
+
def database
|
47
|
+
raise RaysException.new('Database server is not enabled for this project') if @database.nil?
|
48
|
+
@database
|
49
|
+
end
|
50
|
+
|
51
|
+
def database_enabled?
|
52
|
+
@database.nil?
|
53
|
+
end
|
54
|
+
|
55
|
+
def solr
|
56
|
+
raise RaysException.new('SOLR server is not enabled for this project') if @solr.nil?
|
57
|
+
@solr
|
58
|
+
end
|
59
|
+
|
60
|
+
def solr_enabled?
|
61
|
+
@solr.nil?
|
62
|
+
end
|
63
|
+
|
64
|
+
def backup
|
65
|
+
raise RaysException.new('Backup is not enabled for this project') if @backup.nil?
|
66
|
+
@backup
|
67
|
+
end
|
68
|
+
|
69
|
+
def backup_enabled?
|
70
|
+
@backup.nil?
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|