raystool 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -0,0 +1,36 @@
|
|
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
|
+
module AppModule
|
26
|
+
class HookModule < Module
|
27
|
+
register :hook
|
28
|
+
directory 'hooks'
|
29
|
+
archetype 'liferay-hook-archetype'
|
30
|
+
generator Worker::Manager.instance.create :generator, :maven
|
31
|
+
builder Worker::Manager.instance.create :builder, :maven
|
32
|
+
deployer Worker::Manager.instance.create :deployer, :maven
|
33
|
+
cleaner Worker::Manager.instance.create :cleaner, :maven
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
module AppModule
|
26
|
+
class LayoutModule < Module
|
27
|
+
register :layout
|
28
|
+
directory 'layouts'
|
29
|
+
archetype 'liferay-layouttpl-archetype'
|
30
|
+
generator Worker::Manager.instance.create :generator, :maven
|
31
|
+
builder Worker::Manager.instance.create :builder, :maven
|
32
|
+
deployer Worker::Manager.instance.create :deployer, :maven
|
33
|
+
cleaner Worker::Manager.instance.create :cleaner, :maven
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,130 @@
|
|
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
|
+
module AppModule
|
26
|
+
|
27
|
+
#
|
28
|
+
# Facade class for application modules.
|
29
|
+
#
|
30
|
+
class Manager
|
31
|
+
include Singleton
|
32
|
+
attr_reader :module_types
|
33
|
+
|
34
|
+
def initialize
|
35
|
+
@module_types = {}
|
36
|
+
end
|
37
|
+
|
38
|
+
#
|
39
|
+
# Registering new application module type.
|
40
|
+
# Normally used from inside base application module.
|
41
|
+
#
|
42
|
+
def register_module_type(type, module_class)
|
43
|
+
@module_types[type] = module_class
|
44
|
+
end
|
45
|
+
|
46
|
+
#
|
47
|
+
# Instantiate module which has a given directory
|
48
|
+
#
|
49
|
+
def get_from_path(path)
|
50
|
+
return nil if path.nil? or !path.start_with?($rays_config.project_root)
|
51
|
+
|
52
|
+
module_instance = nil
|
53
|
+
directory = Utils::FileUtils.find_up '.module', path, $rays_config.project_root
|
54
|
+
unless directory.nil?
|
55
|
+
module_instance = get_module_from_descriptor(File.join(directory, '.module'))
|
56
|
+
end
|
57
|
+
|
58
|
+
module_instance
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# Find an application module by the given type and name.
|
63
|
+
# Returns application module object or nil if no module is found.
|
64
|
+
#
|
65
|
+
def get(type, name)
|
66
|
+
app_module = nil
|
67
|
+
module_class = @module_types[type]
|
68
|
+
unless module_class.nil?
|
69
|
+
base_path = module_class.base_path
|
70
|
+
in_directory(base_path) do
|
71
|
+
if File.exists?(File.join(base_path, "#{name}/.module"))
|
72
|
+
app_module = module_class.new(name)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
app_module
|
77
|
+
end
|
78
|
+
|
79
|
+
#
|
80
|
+
# Instantiate a module from a given descriptor file.
|
81
|
+
#
|
82
|
+
def get_from_descriptor(descriptor_file)
|
83
|
+
return nil unless File.exists?(descriptor_file)
|
84
|
+
get_module_from_descriptor(descriptor_file)
|
85
|
+
end
|
86
|
+
|
87
|
+
#
|
88
|
+
# Finds all modules in the current project.
|
89
|
+
# If type is specified it will find only the modules of a given type.
|
90
|
+
#
|
91
|
+
def all(type=nil)
|
92
|
+
app_modules = []
|
93
|
+
module_classes = []
|
94
|
+
if type.nil?
|
95
|
+
@module_types.each_value do |module_class|
|
96
|
+
module_classes << module_class
|
97
|
+
end
|
98
|
+
else
|
99
|
+
module_classes = @module_types[type] unless @module_types[type].nil?
|
100
|
+
end
|
101
|
+
|
102
|
+
module_classes.each do |module_class|
|
103
|
+
base_path = module_class.base_path
|
104
|
+
Utils::FileUtils.find_down(base_path, '\.module$').each do |descriptor_file|
|
105
|
+
app_modules << get_module_from_descriptor(descriptor_file)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
app_modules
|
110
|
+
end
|
111
|
+
|
112
|
+
#
|
113
|
+
# Create a new module or initialize if a directory exists but no .module file.
|
114
|
+
#
|
115
|
+
def create(type, name, generator=nil)
|
116
|
+
module_type_class = @module_types[type]
|
117
|
+
raise RaysException.new ("Cannot find module type #{type}") if module_type_class.nil?
|
118
|
+
module_instance = module_type_class.new name
|
119
|
+
module_instance.create generator
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
def get_module_from_descriptor(descriptor_file)
|
125
|
+
module_config = YAML::load_file(descriptor_file)
|
126
|
+
get(module_config['type'], module_config['name'])
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
module AppModule
|
26
|
+
class PortletModule < Module
|
27
|
+
register :portlet
|
28
|
+
directory 'portlets'
|
29
|
+
archetype 'liferay-portlet-archetype'
|
30
|
+
generator Worker::Manager.instance.create :generator, :maven
|
31
|
+
builder Worker::Manager.instance.create :builder, :maven
|
32
|
+
deployer Worker::Manager.instance.create :deployer, :maven
|
33
|
+
cleaner Worker::Manager.instance.create :cleaner, :maven
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
module AppModule
|
26
|
+
class ServiceBuilderModule < Module
|
27
|
+
register :servicebuilder
|
28
|
+
directory 'services'
|
29
|
+
archetype 'liferay-servicebuilder-archetype'
|
30
|
+
generator Worker::Manager.instance.create :generator, :maven
|
31
|
+
builder Worker::Manager.instance.create :builder, :maven
|
32
|
+
deployer Worker::Manager.instance.create :deployer, :maven
|
33
|
+
cleaner Worker::Manager.instance.create :cleaner, :maven
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
module AppModule
|
26
|
+
class ThemeModule < Module
|
27
|
+
register :theme
|
28
|
+
directory 'themes'
|
29
|
+
archetype 'liferay-theme-archetype'
|
30
|
+
generator Worker::Manager.instance.create :generator, :maven
|
31
|
+
builder Worker::Manager.instance.create :builder, :maven
|
32
|
+
deployer Worker::Manager.instance.create :deployer, :maven
|
33
|
+
cleaner Worker::Manager.instance.create :cleaner, :maven
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,116 @@
|
|
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 Project
|
26
|
+
|
27
|
+
attr_reader :name, :package, :liferay
|
28
|
+
|
29
|
+
def initialize
|
30
|
+
project_config_file = "#{$rays_config.project_root}/config/project.yml"
|
31
|
+
project_config = YAML::load_file(project_config_file)
|
32
|
+
@name = project_config['name']
|
33
|
+
@liferay = project_config['liferay']
|
34
|
+
@package = project_config['package']
|
35
|
+
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
#
|
39
|
+
# Get a project instance
|
40
|
+
#
|
41
|
+
def instance
|
42
|
+
self.new
|
43
|
+
end
|
44
|
+
|
45
|
+
#
|
46
|
+
# Create new project with a given name
|
47
|
+
#
|
48
|
+
def create(name)
|
49
|
+
project_root = File.join(Dir.pwd, name)
|
50
|
+
raise RaysException.new("Folder name #{name} already exists") if Dir.exist?(project_root)
|
51
|
+
unless rays_exec("mkdir #{project_root}")
|
52
|
+
raise RaysException.new("Cannot create directory #{name}")
|
53
|
+
end
|
54
|
+
|
55
|
+
copy_template_to project_root
|
56
|
+
init_project(project_root)
|
57
|
+
end
|
58
|
+
|
59
|
+
#
|
60
|
+
# Parse current directory and try to initialize rays project on it.
|
61
|
+
#
|
62
|
+
def init
|
63
|
+
project_root = Dir.pwd
|
64
|
+
is_a_project = true
|
65
|
+
|
66
|
+
begin
|
67
|
+
$rays_config.project_root
|
68
|
+
rescue RaysException => e
|
69
|
+
is_a_project = false
|
70
|
+
end
|
71
|
+
|
72
|
+
if is_a_project
|
73
|
+
raise RaysException.new("this project is already initialized.")
|
74
|
+
end
|
75
|
+
|
76
|
+
project_name = File.basename(Dir.pwd)
|
77
|
+
$log.info("init project #{project_name}")
|
78
|
+
copy_template_to project_root
|
79
|
+
|
80
|
+
init_project(project_name)
|
81
|
+
|
82
|
+
module_types = AppModule::Manager.instance.module_types
|
83
|
+
module_types.values.each do |module_class|
|
84
|
+
names = Utils::FileUtils.find_directories(module_class.base_path)
|
85
|
+
unless names.nil?
|
86
|
+
names.each do |name|
|
87
|
+
AppModule::Manager.instance.create(module_class.type, name)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
$log.info("done")
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def copy_template_to(project_root)
|
97
|
+
template_path = "#{File.expand_path(File.dirname(__FILE__))}/../config/templates/project"
|
98
|
+
Find.find(template_path) do |file|
|
99
|
+
file_base_path = file.sub(template_path, "")
|
100
|
+
next if file_base_path.empty?
|
101
|
+
$log.info("create <!#{file_base_path}!>")
|
102
|
+
FileUtils.cp_r(file, File.join(project_root, file_base_path))
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def init_project(project_root)
|
107
|
+
in_directory(project_root) do
|
108
|
+
project_file = Utils::FileUtils::YamlFile.new('./config/project.yml')
|
109
|
+
project_file.properties['name'] = File.basename(project_root)
|
110
|
+
project_file.write
|
111
|
+
Rays::Core.instance.reload
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,70 @@
|
|
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
|
+
module Server
|
26
|
+
class BaseServer
|
27
|
+
attr_reader :name
|
28
|
+
|
29
|
+
def initialize(name, host, remote, java_home=nil, java_cmd=nil)
|
30
|
+
@name = name
|
31
|
+
@host = host
|
32
|
+
@remote = remote
|
33
|
+
@java_home = java_home
|
34
|
+
@java_cmd = java_cmd
|
35
|
+
default
|
36
|
+
end
|
37
|
+
|
38
|
+
def host
|
39
|
+
raise RaysException.new(missing_environment_option(@name, 'host')) if @host.nil?
|
40
|
+
@host
|
41
|
+
end
|
42
|
+
|
43
|
+
def java_home
|
44
|
+
raise RaysException.new(missing_environment_option(@name, 'java home')) if @java_home.nil?
|
45
|
+
@java_home
|
46
|
+
end
|
47
|
+
|
48
|
+
def java_cmd
|
49
|
+
raise RaysException.new(missing_environment_option(@name, 'java command')) if @java_cmd.nil?
|
50
|
+
@java_cmd
|
51
|
+
end
|
52
|
+
|
53
|
+
def remote?
|
54
|
+
!@remote.nil?
|
55
|
+
end
|
56
|
+
|
57
|
+
def remote
|
58
|
+
raise RaysException.new(missing_environment_option(@name, 'remote access')) if @remote.nil?
|
59
|
+
@remote
|
60
|
+
end
|
61
|
+
|
62
|
+
private
|
63
|
+
def default
|
64
|
+
@host ||= 'localhost'
|
65
|
+
@java_home ||= '/usr/lib/jvm/java-6-sun'
|
66
|
+
@java_cmd ||= '/usr/bin/java'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
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
|
+
module Server
|
26
|
+
class DatabaseServer < BaseServer
|
27
|
+
|
28
|
+
def initialize(name, host, remote, java_home, java_bin, port, db_name, username, password, type)
|
29
|
+
super(name, host, remote, java_home, java_bin)
|
30
|
+
@port = port
|
31
|
+
@db_name = db_name
|
32
|
+
@username = username
|
33
|
+
@password = password
|
34
|
+
@type = type
|
35
|
+
|
36
|
+
@instance = nil
|
37
|
+
if 'mysql'.eql?(@type)
|
38
|
+
@instance = Rays::Database::MySQL.new @host, @port, @username, @password
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def port
|
43
|
+
raise RaysException.new(missing_environment_option('Database server', 'port')) if @port.nil?
|
44
|
+
@port
|
45
|
+
end
|
46
|
+
|
47
|
+
def db_name
|
48
|
+
raise RaysException.new(missing_environment_option('Database server', 'database name')) if @db_name.nil?
|
49
|
+
@db_name
|
50
|
+
end
|
51
|
+
|
52
|
+
def username
|
53
|
+
raise RaysException.new(missing_environment_option('Database server', 'username')) if @username.nil?
|
54
|
+
@username
|
55
|
+
end
|
56
|
+
|
57
|
+
def password
|
58
|
+
raise RaysException.new(missing_environment_option('Database server', 'password')) if @password.nil?
|
59
|
+
@password
|
60
|
+
end
|
61
|
+
|
62
|
+
def type
|
63
|
+
raise RaysException.new(missing_environment_option('Database server', 'type')) if @type.nil?
|
64
|
+
@type
|
65
|
+
end
|
66
|
+
|
67
|
+
def instance
|
68
|
+
raise RaysException.new("Unknown database type #{@type}") if @instance.nil?
|
69
|
+
@instance
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
module Server
|
26
|
+
class LiferayServer < BaseServer
|
27
|
+
|
28
|
+
def initialize(name, host, remote, java_home, java_bin, port, deploy_directory, data_directory, application_service)
|
29
|
+
super(name, host, remote, java_home, java_bin)
|
30
|
+
@port = port
|
31
|
+
@deploy_directory = deploy_directory
|
32
|
+
@data_directory = data_directory
|
33
|
+
@service = application_service
|
34
|
+
default
|
35
|
+
end
|
36
|
+
|
37
|
+
def port
|
38
|
+
raise RaysException.new(missing_environment_option('Liferay', 'port')) if @port.nil?
|
39
|
+
@port
|
40
|
+
end
|
41
|
+
|
42
|
+
def deploy_directory
|
43
|
+
raise RaysException.new(missing_environment_option('Liferay', 'deploy directory')) if @deploy_directory.nil?
|
44
|
+
@deploy_directory
|
45
|
+
end
|
46
|
+
|
47
|
+
def data_directory
|
48
|
+
raise RaysException.new(missing_environment_option('Liferay', 'data directory')) if @data_directory.nil?
|
49
|
+
@data_directory
|
50
|
+
end
|
51
|
+
|
52
|
+
def service
|
53
|
+
raise RaysException.new(missing_environment_option('Liferay', 'service')) if @service.nil?
|
54
|
+
@service
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
def default
|
59
|
+
@port ||= 8080
|
60
|
+
@deploy_directory ||= '/opt/liferay-portal/deploy'
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|