magicmonkey 0.0.10 → 0.1.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/README.rdoc +60 -3
- data/VERSION +1 -1
- data/lib/magic_monkey.rb +40 -41
- metadata +8 -20
- data/.gitignore +0 -21
data/README.rdoc
CHANGED
@@ -1,6 +1,63 @@
|
|
1
|
-
=
|
1
|
+
= Magicmonkey
|
2
2
|
|
3
|
-
|
3
|
+
Magicmonkey is a useful script that can manage your Ruby on Rails application.
|
4
|
+
Magicmonkey allows you to build in easy way the follow web server architecture:
|
5
|
+
|
6
|
+
|
7
|
+
+---------------------------------------------------------------------------------------------------+
|
8
|
+
| Apache web server |
|
9
|
+
| +----------------------+ +----------------------+ +----------------------+ |
|
10
|
+
| |Proxy A (virtual host)| |Proxy B (virtual host)| |Proxy C (virtual host)| |
|
11
|
+
| +---------^------------+ +---------^------------+ +---------^------------+ |
|
12
|
+
| | | | |
|
13
|
+
+-----------|-----------------------------|--------------------------------------|------------------+
|
14
|
+
| | |
|
15
|
+
+-----------v-------------------+ +-------v-----------------------+ +------------v------------------+
|
16
|
+
| Application server standalone | | Application server standalone | | Application server standalone |
|
17
|
+
| Phusion passenger | | Phusion passenger | | Thin |
|
18
|
+
| Ruby 1.9.2 | | Ree 1.8.7 | | Ruby 1.9.2 |
|
19
|
+
| Listen on port 3000 | | Listen on port 3001 | | Listen on port 3002 |
|
20
|
+
| Site foo.com | | Site bar.com | | Site wella.com |
|
21
|
+
+-------------------------------+ +-------------------------------+ +-------------------------------+
|
22
|
+
|
23
|
+
|
24
|
+
Every your web application have a virtual host like this:
|
25
|
+
|
26
|
+
<VirtualHost *:80>
|
27
|
+
ServerName foo.com
|
28
|
+
PassengerEnabled off
|
29
|
+
ProxyPass / http://127.0.0.1:3000/
|
30
|
+
ProxyPassReverse / http://127.0.0.1:3000/
|
31
|
+
</VirtualHost>
|
32
|
+
|
33
|
+
A proxy that speak with an application server standalone mode (like Phusion Passenger v3) that run with a specific Ruby version.
|
34
|
+
To do this you need to have install RVM to manage multiply Ruby versions.
|
35
|
+
|
36
|
+
== Install
|
37
|
+
|
38
|
+
gem install magicmonkey
|
39
|
+
|
40
|
+
== Usage
|
41
|
+
|
42
|
+
First of all you need to say to Magicmonkey that you want manage an application in this way. To to this use the magicmonkey command 'ADD':
|
43
|
+
|
44
|
+
magicmonkey add APP_NAME [options]
|
45
|
+
|
46
|
+
When added, you can start, stop, restart the application
|
47
|
+
|
48
|
+
magicmonkey {start|stop|restart} APP_NAME1, APP_NAME2, ...
|
49
|
+
|
50
|
+
If no application is given start, stop, restart all application.
|
51
|
+
|
52
|
+
You can show the configuration of all your applications with
|
53
|
+
|
54
|
+
magicmonkey show
|
55
|
+
|
56
|
+
Magicmonkey save the configuration in <tt>~/.magicmonkey.yml</tt>
|
57
|
+
|
58
|
+
== Support
|
59
|
+
|
60
|
+
You can use this email address for any questions or help: mailto:enrico@megiston.it.
|
4
61
|
|
5
62
|
== Note on Patches/Pull Requests
|
6
63
|
|
@@ -14,4 +71,4 @@ Description goes here.
|
|
14
71
|
|
15
72
|
== Copyright
|
16
73
|
|
17
|
-
Copyright (c) 2010
|
74
|
+
Copyright (c) 2010 Enrico Pilotto. See LICENSE for details.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0
|
1
|
+
0.1.0
|
data/lib/magic_monkey.rb
CHANGED
@@ -38,7 +38,7 @@ module MagicMonkey
|
|
38
38
|
puts "For more information about a specific command, please type"
|
39
39
|
puts "'magicmonkey <COMMAND> --help', e.g. 'magicmonkey add --help'."
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
def self.show(argv)
|
43
43
|
applications = argv
|
44
44
|
applications = Conf.applications.keys if argv.empty?
|
@@ -53,13 +53,13 @@ module MagicMonkey
|
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
def self.start(argv)
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
58
|
+
v, help = common_options(argv)
|
59
|
+
if help
|
60
|
+
puts 'Start a web application added with ADD command. If no params are given start all web applications.'
|
61
|
+
exit
|
62
|
+
end
|
63
63
|
applications = argv
|
64
64
|
applications = Conf.applications.keys if argv.empty?
|
65
65
|
applications.each do |app_name|
|
@@ -74,44 +74,44 @@ module MagicMonkey
|
|
74
74
|
when 'thin'
|
75
75
|
commands << "thin start -e production -p #{Conf[app_name][:port]} -d"
|
76
76
|
end
|
77
|
-
|
78
|
-
|
77
|
+
print "Starting '#{app_name}' application..."
|
78
|
+
STDOUT.flush
|
79
79
|
output = `bash -c "#{commands.join(' && ')}"`
|
80
|
-
|
81
|
-
|
80
|
+
puts ' done.'
|
81
|
+
print output if v
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
def self.stop(argv)
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
87
|
+
v, help = common_options(argv)
|
88
|
+
if help
|
89
|
+
puts 'Stop a web application added with ADD command. If no params are given stop all web applications.'
|
90
|
+
exit
|
91
|
+
end
|
92
92
|
applications = argv
|
93
93
|
applications = Conf.applications.keys if argv.empty?
|
94
94
|
applications.each do |app_name|
|
95
95
|
if Conf[app_name]
|
96
96
|
commands = []
|
97
|
-
commands << "source '#{Etc.getpwuid.dir}/.rvm/scripts/rvm'"
|
97
|
+
commands << "source '#{Etc.getpwuid.dir}/.rvm/scripts/rvm'" if Conf[app_name][:ruby] != 'auto'
|
98
98
|
commands << "cd '#{Conf[app_name][:app_path]}'"
|
99
|
-
commands << "rvm #{v ? 'use ' : ''}'#{Conf[app_name][:ruby]}'"
|
99
|
+
commands << "rvm #{v ? 'use ' : ''}'#{Conf[app_name][:ruby]}'" if Conf[app_name][:ruby] != 'auto'
|
100
100
|
case Conf[app_name][:app_server]
|
101
101
|
when 'passenger'
|
102
102
|
commands << "passenger stop -p #{Conf[app_name][:port]}"
|
103
103
|
when 'thin'
|
104
104
|
commands << "thin stop -p #{Conf[app_name][:port]}"
|
105
105
|
end
|
106
|
-
|
107
|
-
|
106
|
+
print "Stopping '#{app_name}' application..."
|
107
|
+
STDOUT.flush
|
108
108
|
output = `bash -c "#{commands.join(' && ')}"`
|
109
|
-
|
110
|
-
|
109
|
+
puts ' done.'
|
110
|
+
print output if v
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
def self.restart(argv)
|
116
116
|
applications = argv
|
117
117
|
applications = Conf.applications.keys if argv.empty?
|
@@ -120,7 +120,7 @@ module MagicMonkey
|
|
120
120
|
self.start([app_name])
|
121
121
|
end
|
122
122
|
end
|
123
|
-
|
123
|
+
|
124
124
|
def self.add(argv)
|
125
125
|
options = {}
|
126
126
|
tmp = argv.join('$$').split(/\$\$--\$\$/)
|
@@ -128,11 +128,10 @@ module MagicMonkey
|
|
128
128
|
options[:app_server_options] = tmp[1] ? tmp[1].split('$$').join(' ') : ''
|
129
129
|
servers = ['passenger', 'thin']
|
130
130
|
ports = (3000..4000).to_a.collect{|p| p.to_s}
|
131
|
-
rubies = ['default', '1.9.2', '1.8.7', 'ree']
|
132
131
|
options[:app_server] = servers.first
|
133
132
|
options[:app_path] = '/var/sites/APP_NAME/current'
|
134
133
|
options[:port] = nil
|
135
|
-
options[:ruby] =
|
134
|
+
options[:ruby] = 'auto'
|
136
135
|
options[:vhost_path] = '/etc/apache2/sites-available'
|
137
136
|
vhost_template = "#{Etc.getpwuid.dir}/.magicmonkey.yml"
|
138
137
|
force = false
|
@@ -140,7 +139,7 @@ module MagicMonkey
|
|
140
139
|
enable_site = true
|
141
140
|
reload_apache = false
|
142
141
|
server_name = nil
|
143
|
-
|
142
|
+
|
144
143
|
parser = OptionParser.new do |opts|
|
145
144
|
opts.banner = 'Usage: magicmonkey add APP_NAME [options] [-- application_server_options]'
|
146
145
|
opts.separator ''
|
@@ -161,7 +160,7 @@ module MagicMonkey
|
|
161
160
|
opts.on('-p', '--port NUMBER', ports, "Use the given port number (min: #{ports.first}, max: #{ports.last}).") do |p|
|
162
161
|
options[:port] = p.to_i
|
163
162
|
end
|
164
|
-
opts.on('-r', '--ruby RUBY_VERSION',
|
163
|
+
opts.on('-r', '--ruby RUBY_VERSION', "Use the given Ruby version (default: auto).") do |r|
|
165
164
|
options[:ruby] = r
|
166
165
|
end
|
167
166
|
opts.on('-f', '--[no-]force', "Force mode: replace exist files (default: #{force}).") do |f|
|
@@ -237,7 +236,7 @@ module MagicMonkey
|
|
237
236
|
puts "Application '#{app_name}' already added. You can remove it with 'remove' command."
|
238
237
|
end
|
239
238
|
end
|
240
|
-
|
239
|
+
|
241
240
|
def self.remove(argv)
|
242
241
|
argv.each do |app_name|
|
243
242
|
if Conf[app_name]
|
@@ -253,9 +252,9 @@ module MagicMonkey
|
|
253
252
|
end
|
254
253
|
end
|
255
254
|
end
|
256
|
-
|
255
|
+
|
257
256
|
private
|
258
|
-
|
257
|
+
|
259
258
|
def self.get_port(port)
|
260
259
|
ports = Conf.ports
|
261
260
|
return 3000 if ports.nil? || ports.empty?
|
@@ -264,14 +263,14 @@ module MagicMonkey
|
|
264
263
|
return port
|
265
264
|
end
|
266
265
|
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
266
|
+
def self.common_options(argv)
|
267
|
+
verbose = argv.include?('-v') || argv.include?('--version')
|
268
|
+
help = argv.include?('-h') || argv.include?('--help')
|
269
|
+
argv.delete('-v')
|
270
|
+
argv.delete('--version')
|
271
|
+
argv.delete('-h')
|
272
|
+
argv.delete('--help')
|
273
|
+
return verbose, help
|
274
|
+
end
|
276
275
|
|
277
276
|
end
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magicmonkey
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 10
|
9
|
-
version: 0.0.10
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- pioz
|
@@ -14,7 +10,7 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-06-23 00:00:00 +02:00
|
18
14
|
default_executable: magicmonkey
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
@@ -25,8 +21,6 @@ dependencies:
|
|
25
21
|
requirements:
|
26
22
|
- - ">="
|
27
23
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
24
|
version: "0"
|
31
25
|
type: :development
|
32
26
|
version_requirements: *id001
|
@@ -40,7 +34,6 @@ extra_rdoc_files:
|
|
40
34
|
- LICENSE
|
41
35
|
- README.rdoc
|
42
36
|
files:
|
43
|
-
- .gitignore
|
44
37
|
- LICENSE
|
45
38
|
- README.rdoc
|
46
39
|
- Rakefile
|
@@ -56,8 +49,8 @@ homepage: http://github.com/pioz/magicmonkey
|
|
56
49
|
licenses: []
|
57
50
|
|
58
51
|
post_install_message:
|
59
|
-
rdoc_options:
|
60
|
-
|
52
|
+
rdoc_options: []
|
53
|
+
|
61
54
|
require_paths:
|
62
55
|
- lib
|
63
56
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -65,24 +58,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
58
|
requirements:
|
66
59
|
- - ">="
|
67
60
|
- !ruby/object:Gem::Version
|
68
|
-
segments:
|
69
|
-
- 0
|
70
61
|
version: "0"
|
71
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
63
|
none: false
|
73
64
|
requirements:
|
74
65
|
- - ">="
|
75
66
|
- !ruby/object:Gem::Version
|
76
|
-
segments:
|
77
|
-
- 0
|
78
67
|
version: "0"
|
79
68
|
requirements: []
|
80
69
|
|
81
70
|
rubyforge_project:
|
82
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.6.2
|
83
72
|
signing_key:
|
84
73
|
specification_version: 3
|
85
74
|
summary: "Manage your Rails applications: different Ruby versions and different application servers"
|
86
|
-
test_files:
|
87
|
-
|
88
|
-
- test/test_magic_monkey.rb
|
75
|
+
test_files: []
|
76
|
+
|