magicmonkey 0.1.4 → 1.0.0
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/.gitignore +5 -20
- data/Gemfile +4 -0
- data/bin/magicmonkey +1 -1
- data/lib/magicmonkey/app_servers/passenger.rb +15 -0
- data/lib/magicmonkey/configuration.rb +41 -27
- data/lib/magicmonkey/magicmonkey.rb +320 -41
- data/lib/magicmonkey/version.rb +1 -1
- data/magicmonkey.gemspec +10 -7
- metadata +27 -3
data/.gitignore
CHANGED
@@ -1,21 +1,6 @@
|
|
1
|
-
|
1
|
+
*.gem
|
2
|
+
.bundle
|
3
|
+
.redcar
|
2
4
|
.DS_Store
|
3
|
-
|
4
|
-
|
5
|
-
*.tmproj
|
6
|
-
tmtags
|
7
|
-
|
8
|
-
## EMACS
|
9
|
-
*~
|
10
|
-
\#*
|
11
|
-
.\#*
|
12
|
-
|
13
|
-
## VIM
|
14
|
-
*.swp
|
15
|
-
|
16
|
-
## PROJECT::GENERAL
|
17
|
-
coverage
|
18
|
-
rdoc
|
19
|
-
pkg
|
20
|
-
|
21
|
-
## PROJECT::SPECIFIC
|
5
|
+
Gemfile.lock
|
6
|
+
pkg/*
|
data/Gemfile
ADDED
data/bin/magicmonkey
CHANGED
@@ -0,0 +1,15 @@
|
|
1
|
+
module Passenger
|
2
|
+
|
3
|
+
def self.start(args = {})
|
4
|
+
return "passenger start -e production -p #{args[:port]} #{args[:app_server_options]} -d"
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.stop(args = {})
|
8
|
+
return 'passenger stop'
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.restart(args = {})
|
12
|
+
[self.stop(args), 'sleep 3', self.start(args)]
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -5,64 +5,78 @@ class Conf
|
|
5
5
|
include Singleton
|
6
6
|
attr_reader :config
|
7
7
|
|
8
|
+
VHT = <<EOT
|
9
|
+
<VirtualHost *:80>
|
10
|
+
ServerName $SERVER_NAME
|
11
|
+
ProxyPass / http://127.0.0.1:$PORT/
|
12
|
+
ProxyPassReverse / http://127.0.0.1:$PORT/
|
13
|
+
</VirtualHost>
|
14
|
+
EOT
|
15
|
+
|
16
|
+
DEFAULT = {
|
17
|
+
:app_server => nil,
|
18
|
+
:app_server_options => nil,
|
19
|
+
:port => nil,
|
20
|
+
:ruby => 'default',
|
21
|
+
:app_path => '/var/sites/$APP_NAME/current',
|
22
|
+
:server_name => '$APP_NAME.local',
|
23
|
+
:vhost_template => VHT,
|
24
|
+
:vhost_path => '/etc/apache2/sites-available',
|
25
|
+
:overwrite_files => false,
|
26
|
+
:create_vhost => true,
|
27
|
+
:enable_site => false,
|
28
|
+
:reload_apache => false
|
29
|
+
}
|
30
|
+
|
8
31
|
def initialize
|
9
32
|
load
|
10
33
|
end
|
11
34
|
|
12
35
|
def load
|
13
|
-
@file = "#{
|
36
|
+
@file = "#{Dir.home}/.magicmonkey.yml"
|
14
37
|
if File.exist?(@file)
|
15
38
|
@config = YAML.load_file(@file)
|
16
39
|
else
|
17
|
-
|
18
|
-
vht << "<VirtualHost tagi:80>\n"
|
19
|
-
vht << " ServerName $SERVER_NAME\n"
|
20
|
-
vht << " PassengerEnabled off\n"
|
21
|
-
vht << " ProxyPass / http://127.0.0.1:$PORT/\n"
|
22
|
-
vht << " ProxyPassReverse / http://127.0.0.1:$PORT/\n"
|
23
|
-
vht << "</VirtualHost>\n"
|
24
|
-
@config = {:vhost_template => vht}
|
40
|
+
@config = {:default => DEFAULT}
|
25
41
|
self.save
|
26
42
|
end
|
27
43
|
end
|
28
|
-
|
44
|
+
|
29
45
|
def save
|
30
46
|
File.open(@file, 'w') { |f| f.write(@config.to_yaml) }
|
31
47
|
self.load
|
32
48
|
end
|
33
|
-
|
49
|
+
|
34
50
|
def self.[](key)
|
35
51
|
Conf.instance.config[key.to_sym]
|
36
52
|
end
|
37
|
-
|
53
|
+
|
38
54
|
def self.[]=(key, value)
|
39
55
|
Conf.instance.config[key.to_sym] = value
|
40
56
|
end
|
41
|
-
|
57
|
+
|
42
58
|
def self.delete(key)
|
43
|
-
Conf.instance.config.delete(key.to_sym)
|
59
|
+
Conf.instance.config.delete(key.to_sym) if key.to_sym != :default
|
44
60
|
end
|
45
|
-
|
61
|
+
|
46
62
|
def self.save
|
47
63
|
Conf.instance.save
|
48
64
|
end
|
49
|
-
|
65
|
+
|
50
66
|
def self.applications
|
51
|
-
|
52
|
-
Conf.instance.config.each do |k, v|
|
53
|
-
if k != :vhost_template && k != :uid
|
54
|
-
app[k] = v
|
55
|
-
end
|
56
|
-
end
|
57
|
-
return app
|
67
|
+
Conf.instance.config.keys.select{|k| ![:default, :uid].include?(k)}
|
58
68
|
end
|
59
|
-
|
69
|
+
|
60
70
|
def self.ports
|
61
71
|
p = []
|
62
|
-
Conf.instance.config.each do |k,
|
63
|
-
p << v[:port] if
|
72
|
+
Conf.instance.config.each do |k,v|
|
73
|
+
p << v[:port] if ![:default, :uid].include?(k) && v[:port]
|
64
74
|
end
|
65
75
|
return p
|
66
76
|
end
|
67
|
-
|
77
|
+
|
78
|
+
def self.next_port(range = (3000..5000))
|
79
|
+
return (range.to_a - self.ports).first
|
80
|
+
end
|
81
|
+
|
68
82
|
end
|
@@ -1,61 +1,336 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'pp'
|
3
|
-
require '
|
3
|
+
require 'cocaine'
|
4
|
+
require 'term/ansicolor'
|
4
5
|
require "#{$APP_PATH}/lib/magicmonkey/version"
|
5
6
|
require "#{$APP_PATH}/lib/magicmonkey/configuration"
|
7
|
+
include Term::ANSIColor
|
6
8
|
|
7
9
|
module MagicMonkey
|
10
|
+
|
8
11
|
COMMANDS = [:start, :stop, :restart, :add, :remove, :show]
|
9
12
|
|
10
|
-
def self.main
|
13
|
+
def self.main
|
14
|
+
#Process::UID.change_privilege(Conf[:uid] || Process.uid)
|
11
15
|
raise 'You cannot do this as root' if Process.uid == 0
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
+
|
17
|
+
options = Marshal.load(Marshal.dump(Conf[:default]))
|
18
|
+
parser = OptionParser.new do |opts|
|
19
|
+
opts.banner = 'Usage: magicmonkey <command> [<args>]'
|
20
|
+
opts.separator ''
|
21
|
+
opts.separator "Commands: #{COMMANDS.join(' ')}"
|
22
|
+
opts.separator 'For more information about a specific command, please type'
|
23
|
+
opts.separator "'magicmonkey <command> --help', e.g. 'magicmonkey add --help'"
|
24
|
+
opts.separator ''
|
25
|
+
opts.separator 'Options:'
|
26
|
+
opts.on_tail('-v', '--version', 'Print version') { puts Magicmonkey::VERSION; exit }
|
27
|
+
opts.on_tail('-h', '--help', 'Show this help message') { puts opts; exit }
|
28
|
+
end
|
29
|
+
begin
|
30
|
+
parser.order!
|
31
|
+
command = ARGV[0]
|
32
|
+
ARGV.shift
|
33
|
+
raise 'Invalid command.' unless COMMANDS.include?(command.to_sym)
|
34
|
+
rescue => e
|
35
|
+
rputs e
|
36
|
+
puts parser.help; exit
|
37
|
+
end
|
38
|
+
|
39
|
+
case command
|
40
|
+
when 'add'
|
41
|
+
self.add(ARGV, options)
|
42
|
+
when 'start'
|
43
|
+
start_stop_restart(:start, ARGV)
|
44
|
+
when 'stop'
|
45
|
+
start_stop_restart(:stop, ARGV)
|
46
|
+
when 'restart'
|
47
|
+
start_stop_restart(:restart, ARGV)
|
48
|
+
when 'remove'
|
49
|
+
remove(ARGV)
|
50
|
+
when 'show'
|
51
|
+
show(ARGV)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
|
56
|
+
def self.add(args, o = {})
|
57
|
+
tmp = args.join('$$').split(/\$\$--\$\$/)
|
58
|
+
args = tmp[0].split('$$')
|
59
|
+
o[:app_server_options] = tmp[1] ? tmp[1].split('$$').join(' ') : nil
|
60
|
+
|
61
|
+
parser = OptionParser.new do |opts|
|
62
|
+
opts.banner = 'Usage: magicmonkey add APP_NAME [options] -- application_server_options'
|
63
|
+
opts.separator ''
|
64
|
+
opts.separator 'Options:'
|
65
|
+
opts.on('-s', '--app-server APP_SERVER', "Use the given application server (e.g. passenger, thin, unicorn, default: #{o[:app_server]}).") do |s|
|
66
|
+
o[:app_server] = s
|
67
|
+
end
|
68
|
+
opts.on('-p', '--port NUMBER', Integer, "Use the given port number (default: #{Conf.next_port}).") do |p|
|
69
|
+
o[:port] = p
|
70
|
+
end
|
71
|
+
opts.on('-r', '--ruby RUBY_VERSION', "Use the given Ruby version (default: #{o[:ruby]}).") do |r|
|
72
|
+
o[:ruby] = r
|
73
|
+
end
|
74
|
+
opts.on('--app-path APP_PATH', "Use the given application path (default #{o[:app_path]}).") do |path|
|
75
|
+
o[:app_path] = path
|
76
|
+
end
|
77
|
+
opts.on('--server-name SERVER_NAME', "Use the given server name (default: #{o[:server_name]}).") do |name|
|
78
|
+
o[:server_name] = name
|
79
|
+
end
|
80
|
+
opts.on('--vhost-template TEMPLATE', "Use the given virtual host template file.") do |template|
|
81
|
+
o[:vhost_template] = template
|
82
|
+
end
|
83
|
+
opts.on('--vhost-path VHOST_PATH', "Use the given virtual host path (default: '#{o[:vhost_path]}').") do |path|
|
84
|
+
o[:vhost_path] = path
|
85
|
+
end
|
86
|
+
opts.on('-f', '--[no-]overwrite-files', "Replace exist files (default: #{o[:overwrite_files]}).") do |f|
|
87
|
+
o[:overwrite_files] = f
|
88
|
+
end
|
89
|
+
opts.on('--[no-]create-vhost', "Create virtual host file from template (default: #{o[:create_vhost]}).") do |c|
|
90
|
+
o[:create_vhost] = c
|
91
|
+
end
|
92
|
+
opts.on('--[no-]enable-site', "Enable Apache virtual host (default: #{o[:enable_site]}).") do |e|
|
93
|
+
o[:enable_site] = e
|
94
|
+
end
|
95
|
+
opts.on('--[no-]reload-apache', "Reload apache to load virtual host (default: #{o[:reload_apache]}).") do |r|
|
96
|
+
o[:reload_apache] = r
|
97
|
+
end
|
98
|
+
opts.on_tail('-v', '--version', 'Print version') { puts Magicmonkey::VERSION; exit }
|
99
|
+
opts.on_tail('-h', '--help', 'Show this help message') { puts opts; exit }
|
100
|
+
end
|
101
|
+
begin
|
102
|
+
args = parser.parse!(args)
|
103
|
+
raise 'Missing application name.' if args.size != 1
|
104
|
+
rescue => e
|
105
|
+
rputs e
|
106
|
+
puts parser.help; exit
|
107
|
+
end
|
108
|
+
|
109
|
+
# Ok goo
|
110
|
+
app_name = args.first
|
111
|
+
if Conf.applications.include?(app_name.to_sym)
|
112
|
+
rputs "Application '#{app_name}' already added. Try to use another name."
|
16
113
|
exit
|
17
|
-
|
18
|
-
|
114
|
+
end
|
115
|
+
o[:app_path].gsub!('$APP_NAME', app_name) if o[:app_path] == Conf[:default][:app_path]
|
116
|
+
o[:server_name].gsub!('$APP_NAME', app_name) if o[:server_name] == Conf[:default][:server_name]
|
117
|
+
o[:port] ||= Conf.next_port
|
118
|
+
if Conf.ports.include?(o[:port])
|
119
|
+
rputs 'Invalid port number. This port is used by another application or is invalid.'
|
19
120
|
exit
|
20
|
-
|
21
|
-
|
121
|
+
end
|
122
|
+
self.check_ruby_version!(o[:ruby])
|
123
|
+
self.check_app_server!(o[:app_server])
|
124
|
+
o[:vhost_template].gsub!('$APP_NAME', app_name)
|
125
|
+
o[:vhost_template].gsub!('$SERVER_NAME', o[:server_name])
|
126
|
+
o[:vhost_template].gsub!('$PORT', o[:port].to_s)
|
127
|
+
|
128
|
+
puts "Configuration for application '#{app_name}' is:"
|
129
|
+
pp o
|
130
|
+
print 'Add this application? [Y/n]'
|
131
|
+
input = STDIN.gets.chop
|
132
|
+
if input.upcase == 'Y' || input == ''
|
133
|
+
if o[:create_vhost]
|
134
|
+
vh_file = "#{o[:vhost_path]}/#{app_name}"
|
135
|
+
if (!File.exist?(vh_file) || o[:overwrite_files])
|
136
|
+
begin
|
137
|
+
Cocaine::CommandLine.new('sudo echo', "'#{o[:vhost_template]}' > #{vh_file}").run
|
138
|
+
rescue Cocaine::ExitStatusError => e
|
139
|
+
rputs 'Failed to write virtual host file.'
|
140
|
+
exit
|
141
|
+
end
|
142
|
+
else
|
143
|
+
puts "Virtual host file '#{vh_file}' already exist. Use option '-f' to replace it."
|
144
|
+
exit
|
145
|
+
end
|
146
|
+
end
|
147
|
+
if o[:enable_site]
|
148
|
+
begin
|
149
|
+
Cocaine::CommandLine.new("sudo a2ensite '#{app_name}'").run
|
150
|
+
rescue Cocaine::ExitStatusError => e
|
151
|
+
rputs 'Failed to enable the site.'
|
152
|
+
exit
|
153
|
+
end
|
154
|
+
end
|
155
|
+
if o[:enable_site] && o[:reload_apache]
|
156
|
+
begin
|
157
|
+
Cocaine::CommandLine.new('sudo /etc/init.d/apache2 reload').run
|
158
|
+
rescue Cocaine::ExitStatusError => e
|
159
|
+
rputs 'Failed to reload Apache.'
|
160
|
+
exit
|
161
|
+
end
|
162
|
+
end
|
163
|
+
Conf[app_name] = o
|
164
|
+
Conf.save
|
165
|
+
|
166
|
+
puts "#{green}Application '#{app_name}' added.#{reset}"
|
167
|
+
puts "use 'magicmonkey start #{app_name}' to start the application."
|
22
168
|
end
|
23
169
|
end
|
24
170
|
|
25
|
-
def self.
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
puts
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
171
|
+
def self.remove(args)
|
172
|
+
parser = OptionParser.new do |opts|
|
173
|
+
opts.banner = 'Usage: magicmonkey remove APP_NAME'
|
174
|
+
opts.separator ''
|
175
|
+
opts.separator 'Options:'
|
176
|
+
opts.on_tail('-v', '--version', 'Print version') { puts Magicmonkey::VERSION; exit }
|
177
|
+
opts.on_tail('-h', '--help', 'Show this help message') { puts opts; exit }
|
178
|
+
end
|
179
|
+
begin
|
180
|
+
args = parser.parse!(args)
|
181
|
+
raise 'Missing application name.' if args.size != 1
|
182
|
+
rescue => e
|
183
|
+
rputs e
|
184
|
+
puts parser.help; exit
|
185
|
+
end
|
186
|
+
app_name = args.first
|
187
|
+
if Conf[app_name]
|
188
|
+
vh_file = "#{Conf[app_name][:vhost_path]}/#{app_name}"
|
189
|
+
if File.exist?(vh_file)
|
190
|
+
begin
|
191
|
+
Cocaine::CommandLine.new("sudo a2dissite '#{app_name}' && sudo rm -f '#{vh_file}'").run
|
192
|
+
rescue Cocaine::ExitStatusError => e
|
193
|
+
rputs 'Failed to remove virtual host file.'
|
194
|
+
exit
|
195
|
+
end
|
196
|
+
end
|
197
|
+
Conf.delete(app_name)
|
198
|
+
Conf.save
|
199
|
+
else
|
200
|
+
rputs "Application '#{app_name}' does not exist."
|
201
|
+
end
|
41
202
|
end
|
42
203
|
|
43
|
-
def self.
|
44
|
-
|
45
|
-
|
204
|
+
def self.start_stop_restart(ssr, args)
|
205
|
+
parser = OptionParser.new do |opts|
|
206
|
+
opts.banner = "Usage: magicmonkey #{ssr} [APP_NAME1 ... APP_NAME2 ...]"
|
207
|
+
opts.separator "If no application name passed, #{ssr} all applications."
|
208
|
+
opts.separator ''
|
209
|
+
opts.separator 'Options:'
|
210
|
+
opts.on_tail('-v', '--version', 'Print version') { puts Magicmonkey::VERSION; exit }
|
211
|
+
opts.on_tail('-h', '--help', 'Show this help message') { puts opts; exit }
|
212
|
+
end
|
213
|
+
begin
|
214
|
+
args = parser.parse!(args)
|
215
|
+
rescue => e
|
216
|
+
rputs e
|
217
|
+
puts parser.help; exit
|
218
|
+
end
|
219
|
+
applications = args
|
220
|
+
applications = Conf.applications if applications.empty?
|
46
221
|
applications.each do |app_name|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
222
|
+
o = Conf[app_name.to_sym]
|
223
|
+
if o
|
224
|
+
check_ruby_version!(o[:ruby])
|
225
|
+
server = check_app_server!(o[:app_server])
|
226
|
+
print "Calling #{bold}#{ssr}#{reset} for '#{app_name}' application..."
|
227
|
+
STDOUT.flush
|
228
|
+
begin
|
229
|
+
output = self.run(o){server.send(ssr, o)}
|
230
|
+
puts " #{green}#{bold}done#{reset}."
|
231
|
+
rescue Cocaine::ExitStatusError => e
|
232
|
+
puts ''
|
233
|
+
rputs "Failed to #{ssr} application '#{app_name}'"
|
234
|
+
end
|
52
235
|
else
|
53
|
-
|
236
|
+
rputs "Application '#{app_name}' is not added."
|
237
|
+
rputs "use 'magicmonkey add #{app_name}' to add this application."
|
54
238
|
end
|
55
239
|
end
|
56
240
|
end
|
57
241
|
|
58
|
-
def self.
|
242
|
+
def self.show(args)
|
243
|
+
parser = OptionParser.new do |opts|
|
244
|
+
opts.banner = "Usage: magicmonkey show [APP_NAME1 ... APP_NAME2 ...]"
|
245
|
+
opts.separator 'If no application name passed, show the configuration of all applications.'
|
246
|
+
opts.separator ''
|
247
|
+
opts.separator 'Options:'
|
248
|
+
opts.on_tail('-v', '--version', 'Print version') { puts Magicmonkey::VERSION; exit }
|
249
|
+
opts.on_tail('-h', '--help', 'Show this help message') { puts opts; exit }
|
250
|
+
end
|
251
|
+
begin
|
252
|
+
args = parser.parse!(args)
|
253
|
+
rescue => e
|
254
|
+
rputs e
|
255
|
+
puts parser.help; exit
|
256
|
+
end
|
257
|
+
applications = args
|
258
|
+
applications = Conf.applications if applications.empty?
|
259
|
+
applications.each do |app_name|
|
260
|
+
pp Conf[app_name]
|
261
|
+
puts '-'*80
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
private
|
266
|
+
|
267
|
+
def self.check_ruby_version!(ruby)
|
268
|
+
rubies = ['default', 'system']
|
269
|
+
begin
|
270
|
+
res = Cocaine::CommandLine.new('rvm list').run
|
271
|
+
rescue Cocaine::CommandNotFoundError
|
272
|
+
rputs 'RVM (Ruby Verison Manager) is not installed in your system. Please install RVM to use Magicmonkey.'
|
273
|
+
exit
|
274
|
+
end
|
275
|
+
res.each_line do |line|
|
276
|
+
match = line.match(/\s((?:ruby|jruby|rbx|ree|macruby|maglev|ironruby)\S+?)\s/)
|
277
|
+
rubies << match[1] if match
|
278
|
+
end
|
279
|
+
unless rubies.include?(ruby)
|
280
|
+
rputs "Ruby version specified ('#{ruby}') is not installed in your system."
|
281
|
+
rputs "Valid Ruby versions are: #{rubies.join(', ')}."
|
282
|
+
exit
|
283
|
+
end
|
284
|
+
end
|
285
|
+
|
286
|
+
def self.check_app_server!(app_server)
|
287
|
+
unless app_server
|
288
|
+
rputs 'You must specify the application server.'
|
289
|
+
rputs 'Please use --app-server option. e.g. magicmonkey add APP_NAME --app-server=passenger'
|
290
|
+
exit
|
291
|
+
end
|
292
|
+
begin
|
293
|
+
Cocaine::CommandLine.new(app_server).run
|
294
|
+
rescue Cocaine::CommandNotFoundError
|
295
|
+
rputs "The application server '#{app_server}' is not installed in your system."
|
296
|
+
rputs 'Please use a valid and installed application server.'
|
297
|
+
exit
|
298
|
+
rescue
|
299
|
+
end
|
300
|
+
begin
|
301
|
+
require "#{$APP_PATH}/lib/magicmonkey/app_servers/#{app_server}"
|
302
|
+
const_get(app_server.capitalize)
|
303
|
+
rescue LoadError, NameError
|
304
|
+
rputs "No module '#{app_server.capitalize}' found in #{$APP_PATH}/lib/magicmonkey/app_servers/#{app_server}.rb"
|
305
|
+
rputs "You must create a module called '#{app_server.capitalize}' to tell how to start, stop and restart the server."
|
306
|
+
exit
|
307
|
+
end
|
308
|
+
end
|
309
|
+
|
310
|
+
def self.run(options)
|
311
|
+
lines = []
|
312
|
+
lines << "source #{Dir.home}/.rvm/scripts/rvm"
|
313
|
+
lines << "rvm use #{options[:ruby]}"
|
314
|
+
lines << "cd #{options[:app_path]}"
|
315
|
+
res = yield
|
316
|
+
if res.class == Array
|
317
|
+
lines += res
|
318
|
+
elsif res.class == String
|
319
|
+
lines << res
|
320
|
+
end
|
321
|
+
line = Cocaine::CommandLine.new("bash -c '#{lines.join(' && ')}'")
|
322
|
+
line.run
|
323
|
+
end
|
324
|
+
|
325
|
+
def self.rputs(message)
|
326
|
+
puts "#{red}#{message}#{reset}"
|
327
|
+
end
|
328
|
+
|
329
|
+
end
|
330
|
+
|
331
|
+
__END__
|
332
|
+
|
333
|
+
def self.start2(argv)
|
59
334
|
v, help = common_options(argv)
|
60
335
|
if help
|
61
336
|
puts 'Start a web application added with ADD command. If no params are given start all web applications.'
|
@@ -67,7 +342,7 @@ module MagicMonkey
|
|
67
342
|
if Conf[app_name]
|
68
343
|
commands = []
|
69
344
|
if Conf[app_name][:ruby] != 'auto'
|
70
|
-
commands << "source '#{
|
345
|
+
commands << "source '#{Dir.home}/.rvm/scripts/rvm'"
|
71
346
|
commands << "rvm #{v ? 'use ' : ''}'#{Conf[app_name][:ruby]}'"
|
72
347
|
end
|
73
348
|
commands << "cd '#{Conf[app_name][:app_path]}'"
|
@@ -86,7 +361,7 @@ module MagicMonkey
|
|
86
361
|
end
|
87
362
|
end
|
88
363
|
|
89
|
-
def self.
|
364
|
+
def self.stop2(argv)
|
90
365
|
v, help = common_options(argv)
|
91
366
|
if help
|
92
367
|
puts 'Stop a web application added with ADD command. If no params are given stop all web applications.'
|
@@ -117,7 +392,7 @@ module MagicMonkey
|
|
117
392
|
end
|
118
393
|
end
|
119
394
|
|
120
|
-
def self.
|
395
|
+
def self.restart2(argv)
|
121
396
|
applications = argv
|
122
397
|
applications = Conf.applications.keys if argv.empty?
|
123
398
|
applications.each do |app_name|
|
@@ -126,7 +401,7 @@ module MagicMonkey
|
|
126
401
|
end
|
127
402
|
end
|
128
403
|
|
129
|
-
def self.
|
404
|
+
def self.add2(argv)
|
130
405
|
options = {}
|
131
406
|
tmp = argv.join('$$').split(/\$\$--\$\$/)
|
132
407
|
argv = tmp[0].split('$$')
|
@@ -138,7 +413,7 @@ module MagicMonkey
|
|
138
413
|
options[:port] = nil
|
139
414
|
options[:ruby] = 'auto'
|
140
415
|
options[:vhost_path] = '/etc/apache2/sites-available'
|
141
|
-
vhost_template = "#{
|
416
|
+
vhost_template = "#{Dir.home}/.magicmonkey.yml"
|
142
417
|
force = false
|
143
418
|
create_vhost = true
|
144
419
|
enable_site = true
|
@@ -261,6 +536,10 @@ module MagicMonkey
|
|
261
536
|
|
262
537
|
private
|
263
538
|
|
539
|
+
def self.rputs(message)
|
540
|
+
puts "#{red}#{message}#{reset}"
|
541
|
+
end
|
542
|
+
|
264
543
|
def self.get_port(port = nil)
|
265
544
|
ports = Conf.ports
|
266
545
|
return 3000 if ports.nil? || ports.empty?
|
data/lib/magicmonkey/version.rb
CHANGED
data/magicmonkey.gemspec
CHANGED
@@ -1,17 +1,20 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'magicmonkey/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'magicmonkey'
|
7
7
|
s.version = Magicmonkey::VERSION
|
8
|
-
s.authors = [
|
9
|
-
s.email = [
|
10
|
-
s.homepage =
|
8
|
+
s.authors = ['Enrico Pilotto']
|
9
|
+
s.email = ['enrico@megiston.it']
|
10
|
+
s.homepage = 'https://github.com/pioz/magicmonkey'
|
11
11
|
s.summary = %q{Manage your Rails applications: different Ruby versions and different application servers}
|
12
12
|
s.description = %q{Manage your Rails applications: different Ruby versions and different application servers.}
|
13
13
|
|
14
|
-
s.rubyforge_project =
|
14
|
+
s.rubyforge_project = 'magicmonkey'
|
15
|
+
|
16
|
+
s.add_dependency('cocaine')
|
17
|
+
s.add_dependency('term-ansicolor')
|
15
18
|
|
16
19
|
s.files = `git ls-files`.split("\n")
|
17
20
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magicmonkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,8 +9,30 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-10-
|
13
|
-
dependencies:
|
12
|
+
date: 2011-10-25 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: cocaine
|
16
|
+
requirement: &70225761834040 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70225761834040
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: term-ansicolor
|
27
|
+
requirement: &70225761833500 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70225761833500
|
14
36
|
description: ! 'Manage your Rails applications: different Ruby versions and different
|
15
37
|
application servers.'
|
16
38
|
email:
|
@@ -21,10 +43,12 @@ extensions: []
|
|
21
43
|
extra_rdoc_files: []
|
22
44
|
files:
|
23
45
|
- .gitignore
|
46
|
+
- Gemfile
|
24
47
|
- LICENSE
|
25
48
|
- README.rdoc
|
26
49
|
- Rakefile
|
27
50
|
- bin/magicmonkey
|
51
|
+
- lib/magicmonkey/app_servers/passenger.rb
|
28
52
|
- lib/magicmonkey/configuration.rb
|
29
53
|
- lib/magicmonkey/magicmonkey.rb
|
30
54
|
- lib/magicmonkey/version.rb
|