railsmachine 0.1.2 → 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/README +21 -1
- data/Rakefile +3 -4
- data/lib/railsmachine/generators/railsmachine/templates/deploy.rb +9 -2
- data/lib/railsmachine/recipes.rb +133 -107
- data/lib/railsmachine/recipes/apache.rb +46 -39
- data/lib/railsmachine/recipes/mongrel.rb +127 -1
- data/lib/railsmachine/recipes/mysql.rb +21 -17
- data/lib/railsmachine/recipes/pgsql.rb +13 -17
- data/lib/railsmachine/recipes/svn.rb +40 -36
- metadata +15 -24
data/README
CHANGED
@@ -1,3 +1,23 @@
|
|
1
1
|
== Railsmachine
|
2
2
|
|
3
|
-
|
3
|
+
A set of capistrano recipes for simplifying the deployment of Rails applications.
|
4
|
+
|
5
|
+
The deployment process looks like this:
|
6
|
+
|
7
|
+
cd <app_directory>
|
8
|
+
capify .
|
9
|
+
railsmachine --apply-to . --name <app_name> --domain <yourdomain.com>
|
10
|
+
cap repos:setup
|
11
|
+
cd ../<app_name>_machine
|
12
|
+
cap servers:setup deploy:cold
|
13
|
+
|
14
|
+
Under the default configuration the gem will use these directories:
|
15
|
+
|
16
|
+
/var/www/apps/ - Rails applications
|
17
|
+
/etc/httpd/conf/apps/ - Apache configurations
|
18
|
+
/var/run/mongrel_cluster/ - Mongrel pid files
|
19
|
+
/etc/mongrel_cluster/ - Mongrel cluster configurations
|
20
|
+
|
21
|
+
You will need a 'deploy' system account with write access to the above directories.
|
22
|
+
You also need a 'deploy' mysql account with all privileges on *.* and grant option.
|
23
|
+
|
data/Rakefile
CHANGED
@@ -15,15 +15,14 @@ setup_rdoc ['README', 'LICENSE', 'COPYING', 'lib/**/*.rb', 'doc/**/*.rdoc']
|
|
15
15
|
desc "Does a full compile, test run"
|
16
16
|
task :default => [:test, :package]
|
17
17
|
|
18
|
-
version="0.
|
18
|
+
version="1.0.0"
|
19
19
|
name="railsmachine"
|
20
20
|
|
21
21
|
setup_gem(name, version) do |spec|
|
22
22
|
spec.summary = "The Rails Machine task library"
|
23
23
|
spec.description = spec.summary
|
24
|
-
spec.author="Bradley Taylor"
|
25
|
-
spec.add_dependency('capistrano', '>=
|
26
|
-
spec.add_dependency('mongrel_cluster', '>= 0.2.0')
|
24
|
+
spec.author="Bradley Taylor, Rob Lingle"
|
25
|
+
spec.add_dependency('capistrano', '>= 2.0.0')
|
27
26
|
spec.has_rdoc = false
|
28
27
|
spec.files += Dir.glob("bin/*")
|
29
28
|
spec.files += Dir.glob("resources/**/*")
|
@@ -72,17 +72,24 @@ role :scm, domain
|
|
72
72
|
# set :mongrel_port, apache_proxy_port
|
73
73
|
# set :mongrel_address, apache_proxy_address
|
74
74
|
# set :mongrel_environment, "production"
|
75
|
+
# set :mongrel_pid_file, "/var/run/mongrel_cluster/#{application}.pid"
|
75
76
|
# set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf"
|
76
77
|
# set :mongrel_user, user
|
77
78
|
# set :mongrel_group, group
|
78
79
|
|
79
80
|
# =============================================================================
|
80
|
-
#
|
81
|
+
# SCM OPTIONS
|
81
82
|
# =============================================================================
|
82
|
-
|
83
|
+
#set :scm,"subversion"
|
83
84
|
|
84
85
|
# =============================================================================
|
85
86
|
# SSH OPTIONS
|
86
87
|
# =============================================================================
|
87
88
|
# ssh_options[:keys] = %w(/path/to/my/key /path/to/another/key)
|
88
89
|
# ssh_options[:port] = 25
|
90
|
+
|
91
|
+
# =============================================================================
|
92
|
+
# CAPISTRANO OPTIONS
|
93
|
+
# =============================================================================
|
94
|
+
# default_run_options[:pty] = true
|
95
|
+
# set :keep_releases, 3
|
data/lib/railsmachine/recipes.rb
CHANGED
@@ -1,135 +1,161 @@
|
|
1
1
|
require 'railsmachine/recipes/svn'
|
2
2
|
require 'railsmachine/recipes/mysql'
|
3
|
+
require 'railsmachine/recipes/pgsql'
|
3
4
|
require 'railsmachine/recipes/apache'
|
4
5
|
require 'railsmachine/recipes/mongrel'
|
5
6
|
|
6
|
-
Capistrano.
|
7
|
-
set :app_symlinks, nil
|
8
|
-
|
9
|
-
desc <<-DESC
|
10
|
-
A macro task that calls setup, setup_db, setup_app, setup_symlinks, and setup_web.
|
11
|
-
Used to configure your deployment environment in one command.
|
12
|
-
DESC
|
13
|
-
task :setup_servers do
|
14
|
-
setup
|
15
|
-
begin
|
16
|
-
setup_db
|
17
|
-
rescue
|
18
|
-
puts "setup_db failed!"
|
19
|
-
end
|
20
|
-
setup_app
|
21
|
-
setup_symlinks
|
22
|
-
setup_web
|
23
|
-
end
|
24
|
-
|
25
|
-
desc <<-DESC
|
26
|
-
A macro task that calls setup_db, setup_app, setup_symlinks, and setup_web.
|
27
|
-
Used to configure your deployment environment in one command.
|
28
|
-
DESC
|
29
|
-
task :setup_app, :roles => :app do
|
30
|
-
set :mongrel_environment, rails_env
|
31
|
-
set :mongrel_port, apache_proxy_port
|
32
|
-
set :mongrel_servers, apache_proxy_servers
|
33
|
-
set :mongrel_user, user unless mongrel_user
|
34
|
-
set :mongrel_group, mongrel_user unless mongrel_group
|
35
|
-
set_mongrel_conf
|
36
|
-
configure_mongrel_cluster
|
37
|
-
end
|
7
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
38
8
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
restart_mongrel_cluster
|
43
|
-
end
|
9
|
+
default_run_options[:pty] = true
|
10
|
+
set :keep_releases, 3
|
11
|
+
set :app_symlinks, nil
|
44
12
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
13
|
+
namespace :servers do
|
14
|
+
|
15
|
+
desc <<-DESC
|
16
|
+
A macro task that calls setup for db, app, symlinks, and web.
|
17
|
+
Used to configure your deployment environment in one command.
|
18
|
+
DESC
|
19
|
+
task :setup do
|
20
|
+
deploy.setup
|
21
|
+
begin
|
22
|
+
db.setup
|
23
|
+
rescue
|
24
|
+
puts "db:setup failed!"
|
25
|
+
end
|
26
|
+
app.setup
|
27
|
+
web.setup
|
28
|
+
end
|
50
29
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
30
|
+
desc "A macro task that restarts the application and web servers"
|
31
|
+
task :restart do
|
32
|
+
app.restart
|
33
|
+
web.restart
|
34
|
+
end
|
56
35
|
|
57
|
-
def set_mongrel_conf
|
58
|
-
set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
|
59
|
-
end
|
60
|
-
|
61
|
-
desc "Setup web server."
|
62
|
-
task :setup_web, :roles => :web do
|
63
|
-
set :apache_server_name, domain unless apache_server_name
|
64
|
-
configure_apache
|
65
36
|
end
|
66
37
|
|
67
|
-
|
68
|
-
task :restart_web, :roles => :web do
|
69
|
-
restart_apache
|
70
|
-
end
|
38
|
+
namespace :app do
|
71
39
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
40
|
+
desc 'Setup mongrel'
|
41
|
+
task :setup, :roles => :app do
|
42
|
+
set :mongrel_environment, rails_env
|
43
|
+
set :mongrel_port, apache_proxy_port
|
44
|
+
set :mongrel_servers, apache_proxy_servers
|
45
|
+
set :mongrel_user, user unless mongrel_user
|
46
|
+
set :mongrel_group, mongrel_user unless mongrel_group
|
47
|
+
set_mongrel_conf
|
48
|
+
mongrel.cluster.configure
|
49
|
+
end
|
50
|
+
|
51
|
+
desc "Restart application server."
|
52
|
+
task :restart, :roles => :app do
|
53
|
+
set_mongrel_conf
|
54
|
+
mongrel.cluster.restart
|
55
|
+
end
|
56
|
+
|
57
|
+
desc "Start application server."
|
58
|
+
task :start, :roles => :app do
|
59
|
+
set_mongrel_conf
|
60
|
+
mongrel.cluster.start
|
61
|
+
end
|
62
|
+
|
63
|
+
desc "Stop application server."
|
64
|
+
task :stop, :roles => :app do
|
65
|
+
set_mongrel_conf
|
66
|
+
mongrel.cluster.stop
|
67
|
+
end
|
76
68
|
|
77
|
-
|
78
|
-
task :start_web, :roles => :web do
|
79
|
-
start_apache
|
80
|
-
end
|
69
|
+
namespace :symlinks do
|
81
70
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
71
|
+
desc "Setup application symlinks in the public"
|
72
|
+
task :setup, :roles => [:app, :web] do
|
73
|
+
if app_symlinks
|
74
|
+
app_symlinks.each { |link| run "mkdir -p #{shared_path}/public/#{link}" }
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Link public directories to shared location."
|
79
|
+
task :update, :roles => [:app, :web] do
|
80
|
+
if app_symlinks
|
81
|
+
app_symlinks.each { |link| run "ln -nfs #{shared_path}/public/#{link} #{current_path}/public/#{link}" }
|
82
|
+
end
|
83
|
+
end
|
86
84
|
|
87
|
-
|
88
|
-
task :setup_db, :roles => :db, :only => { :primary => true } do
|
89
|
-
setup_mysql
|
90
|
-
end
|
85
|
+
end
|
91
86
|
|
92
|
-
desc "Setup source control server."
|
93
|
-
task :setup_scm, :roles => :scm do
|
94
|
-
begin
|
95
|
-
setup_svn
|
96
|
-
rescue
|
97
|
-
puts "setup_svn failed!"
|
98
|
-
end
|
99
|
-
import_svn
|
100
87
|
end
|
101
88
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
89
|
+
namespace :web do
|
90
|
+
|
91
|
+
desc "Setup web server."
|
92
|
+
task :setup, :roles => :web do
|
93
|
+
set :apache_server_name, domain unless apache_server_name
|
94
|
+
apache.configure
|
95
|
+
end
|
96
|
+
|
97
|
+
desc "Restart web server."
|
98
|
+
task :restart, :roles => :web do
|
99
|
+
apache.restart
|
106
100
|
end
|
101
|
+
|
102
|
+
desc "Reload web server configuration."
|
103
|
+
task :reload, :roles => :web do
|
104
|
+
apache.reload
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Start web server."
|
108
|
+
task :start, :roles => :web do
|
109
|
+
apache.start
|
110
|
+
end
|
111
|
+
|
112
|
+
desc "Stop web server."
|
113
|
+
task :stop, :roles => :web do
|
114
|
+
apache.stop
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
namespace :db do
|
120
|
+
|
121
|
+
desc "Setup database server."
|
122
|
+
task :setup, :roles => :db, :only => { :primary => true } do
|
123
|
+
db_config = YAML.load_file('config/database.yml')
|
124
|
+
db_type = db_config[rails_env]["adapter"]
|
125
|
+
case db_config[rails_env]["adapter"]
|
126
|
+
when "mysql"
|
127
|
+
mysql.setup
|
128
|
+
when "postgresql"
|
129
|
+
postgresql.setup
|
130
|
+
else
|
131
|
+
puts "Only MySQL or Postgres can be configured by db:setup."
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
107
135
|
end
|
108
136
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
137
|
+
namespace :repos do
|
138
|
+
|
139
|
+
desc "Setup source control repository."
|
140
|
+
task :setup, :roles => :scm do
|
141
|
+
begin
|
142
|
+
svn.setup
|
143
|
+
rescue
|
144
|
+
puts "svn:setup failed!"
|
113
145
|
end
|
114
|
-
|
146
|
+
svn.import
|
147
|
+
end
|
115
148
|
|
116
|
-
desc <<-DESC
|
117
|
-
Restart the processes on the application server by calling restart_app.
|
118
|
-
DESC
|
119
|
-
task :restart, :roles => :app do
|
120
|
-
restart_app
|
121
149
|
end
|
122
150
|
|
123
|
-
desc <<-DESC
|
124
|
-
Start the processes on the application server by calling start_app.
|
125
|
-
DESC
|
126
|
-
task :spinner, :roles => :app do
|
127
|
-
start_app
|
128
|
-
end
|
129
151
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
152
|
+
before 'deploy:update_code', 'app:symlinks:setup'
|
153
|
+
after 'deploy:symlink', 'app:symlinks:update'
|
154
|
+
after 'deploy:cold', 'web:reload'
|
155
|
+
after :deploy,'deploy:cleanup'
|
156
|
+
|
157
|
+
def set_mongrel_conf
|
158
|
+
set :mongrel_conf, "/etc/mongrel_cluster/#{application}.conf" unless mongrel_conf
|
159
|
+
end
|
134
160
|
|
135
161
|
end
|
@@ -1,4 +1,5 @@
|
|
1
|
-
|
1
|
+
require 'erb'
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
3
|
|
3
4
|
set :apache_server_name, nil
|
4
5
|
set :apache_conf, nil
|
@@ -13,49 +14,55 @@ Capistrano.configuration(:must_exist).load do
|
|
13
14
|
set :apache_ssl_ip, nil
|
14
15
|
set :apache_ssl_forward_all, false
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
17
|
+
namespace :apache do
|
18
|
+
|
19
|
+
desc "Configure Apache. This uses the :use_sudo
|
20
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
21
|
+
set to true."
|
22
|
+
task :configure, :roles => :web do
|
23
|
+
set_apache_conf
|
24
|
+
|
25
|
+
server_aliases = []
|
26
|
+
server_aliases << "www.#{apache_server_name}"
|
27
|
+
server_aliases.concat apache_server_aliases
|
28
|
+
set :apache_server_aliases_array, server_aliases
|
29
|
+
|
30
|
+
file = File.join(File.dirname(__FILE__), "templates", "httpd.conf")
|
31
|
+
template = File.read(file)
|
32
|
+
buffer = ERB.new(template).result(binding)
|
33
|
+
|
34
|
+
if apache_ssl_enabled
|
35
|
+
file = File.join(File.dirname(__FILE__), "templates", "httpd-ssl.conf")
|
36
|
+
template = File.read(file)
|
37
|
+
ssl_buffer = ERB.new(template).result(binding)
|
38
|
+
buffer += ssl_buffer
|
39
|
+
end
|
40
|
+
|
41
|
+
put buffer, "#{shared_path}/httpd.conf", :mode => 0444
|
42
|
+
send(run_method, "cp #{shared_path}/httpd.conf #{apache_conf}")
|
43
|
+
send(run_method, "rm -f #{shared_path}/httpd.conf")
|
44
|
+
end
|
21
45
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
46
|
+
desc "Start Apache "
|
47
|
+
task :start, :roles => :web do
|
48
|
+
send(run_method, "#{apache_ctl} start")
|
49
|
+
end
|
26
50
|
|
27
|
-
|
28
|
-
|
51
|
+
desc "Restart Apache "
|
52
|
+
task :restart, :roles => :web do
|
53
|
+
send(run_method, "#{apache_ctl} restart")
|
54
|
+
end
|
29
55
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
buffer += ssl_buffer
|
56
|
+
desc "Stop Apache "
|
57
|
+
task :stop, :roles => :web do
|
58
|
+
send(run_method, "#{apache_ctl} stop")
|
34
59
|
end
|
35
60
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
desc "Start Apache "
|
42
|
-
task :start_apache, :roles => :web do
|
43
|
-
send(run_method, "#{apache_ctl} start")
|
44
|
-
end
|
45
|
-
|
46
|
-
desc "Restart Apache "
|
47
|
-
task :restart_apache, :roles => :web do
|
48
|
-
send(run_method, "#{apache_ctl} restart")
|
49
|
-
end
|
50
|
-
|
51
|
-
desc "Stop Apache "
|
52
|
-
task :stop_apache, :roles => :web do
|
53
|
-
send(run_method, "#{apache_ctl} stop")
|
54
|
-
end
|
61
|
+
desc "Reload Apache "
|
62
|
+
task :reload, :roles => :web do
|
63
|
+
send(run_method, "#{apache_ctl} reload")
|
64
|
+
end
|
55
65
|
|
56
|
-
desc "Reload Apache "
|
57
|
-
task :reload_apache, :roles => :web do
|
58
|
-
send(run_method, "#{apache_ctl} reload")
|
59
66
|
end
|
60
67
|
|
61
68
|
def set_apache_conf
|
@@ -66,4 +73,4 @@ Capistrano.configuration(:must_exist).load do
|
|
66
73
|
end
|
67
74
|
end
|
68
75
|
|
69
|
-
end
|
76
|
+
end
|
@@ -1 +1,127 @@
|
|
1
|
-
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
set :mongrel_servers, 2
|
3
|
+
set :mongrel_port, 8000
|
4
|
+
set :mongrel_address, "127.0.0.1"
|
5
|
+
set :mongrel_environment, "production"
|
6
|
+
set :mongrel_conf, nil
|
7
|
+
set :mongrel_user, nil
|
8
|
+
set :mongrel_group, nil
|
9
|
+
set :mongrel_prefix, nil
|
10
|
+
set :mongrel_rails, 'mongrel_rails'
|
11
|
+
set :mongrel_clean, false
|
12
|
+
set :mongrel_pid_file, nil
|
13
|
+
set :mongrel_log_file, nil
|
14
|
+
set :mongrel_config_script, nil
|
15
|
+
|
16
|
+
namespace :mongrel do
|
17
|
+
|
18
|
+
namespace :cluster do
|
19
|
+
|
20
|
+
desc <<-DESC
|
21
|
+
Configure Mongrel processes on the app server. This uses the :use_sudo
|
22
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
23
|
+
set to true.
|
24
|
+
DESC
|
25
|
+
task :configure, :roles => :app do
|
26
|
+
set_mongrel_conf
|
27
|
+
set_mongrel_pid_file
|
28
|
+
|
29
|
+
argv = []
|
30
|
+
argv << "#{mongrel_rails} cluster::configure"
|
31
|
+
argv << "-N #{mongrel_servers.to_s}"
|
32
|
+
argv << "-p #{mongrel_port.to_s}"
|
33
|
+
argv << "-e #{mongrel_environment}"
|
34
|
+
argv << "-a #{mongrel_address}"
|
35
|
+
argv << "-c #{current_path}"
|
36
|
+
argv << "-C #{mongrel_conf}"
|
37
|
+
argv << "-P #{mongrel_pid_file}"
|
38
|
+
argv << "-l #{mongrel_log_file}" if mongrel_log_file
|
39
|
+
argv << "--user #{mongrel_user}" if mongrel_user
|
40
|
+
argv << "--group #{mongrel_group}" if mongrel_group
|
41
|
+
argv << "--prefix #{mongrel_prefix}" if mongrel_prefix
|
42
|
+
argv << "-S #{mongrel_config_script}" if mongrel_config_script
|
43
|
+
cmd = argv.join " "
|
44
|
+
send(run_method, cmd)
|
45
|
+
end
|
46
|
+
|
47
|
+
desc <<-DESC
|
48
|
+
Start Mongrel processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
|
49
|
+
set to true.
|
50
|
+
DESC
|
51
|
+
task :start, :roles => :app do
|
52
|
+
set_mongrel_conf
|
53
|
+
cmd = "#{mongrel_rails} cluster::start -C #{mongrel_conf}"
|
54
|
+
cmd += " --clean" if mongrel_clean
|
55
|
+
send(run_method, cmd)
|
56
|
+
end
|
57
|
+
|
58
|
+
desc <<-DESC
|
59
|
+
Restart the Mongrel processes on the app server by starting and stopping the cluster. This uses the :use_sudo
|
60
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
|
61
|
+
DESC
|
62
|
+
task :restart, :roles => :app do
|
63
|
+
set_mongrel_conf
|
64
|
+
cmd = "#{mongrel_rails} cluster::restart -C #{mongrel_conf}"
|
65
|
+
cmd += " --clean" if mongrel_clean
|
66
|
+
send(run_method, cmd)
|
67
|
+
end
|
68
|
+
|
69
|
+
desc <<-DESC
|
70
|
+
Stop the Mongrel processes on the app server. This uses the :use_sudo
|
71
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
72
|
+
set to true.
|
73
|
+
DESC
|
74
|
+
task :stop, :roles => :app do
|
75
|
+
set_mongrel_conf
|
76
|
+
cmd = "#{mongrel_rails} cluster::stop -C #{mongrel_conf}"
|
77
|
+
cmd += " --clean" if mongrel_clean
|
78
|
+
send(run_method, cmd)
|
79
|
+
end
|
80
|
+
|
81
|
+
desc <<-DESC
|
82
|
+
Check the status of the Mongrel processes on the app server. This uses the :use_sudo
|
83
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
84
|
+
set to true.
|
85
|
+
DESC
|
86
|
+
task :status, :roles => :app do
|
87
|
+
set_mongrel_conf
|
88
|
+
send(run_method, "#{mongrel_rails} cluster::status -C #{mongrel_conf}")
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
namespace :deploy do
|
96
|
+
|
97
|
+
desc <<-DESC
|
98
|
+
Start the Mongrel processes on the app server by calling start_mongrel_cluster.
|
99
|
+
DESC
|
100
|
+
task :start, :roles => :app do
|
101
|
+
mongrel.cluster.start
|
102
|
+
end
|
103
|
+
|
104
|
+
desc <<-DESC
|
105
|
+
Restart the Mongrel processes on the app server by calling restart_mongrel_cluster.
|
106
|
+
DESC
|
107
|
+
task :restart, :roles => :app do
|
108
|
+
mongrel.cluster.restart
|
109
|
+
end
|
110
|
+
|
111
|
+
desc <<-DESC
|
112
|
+
Stop the Mongrel processes on the app server by calling stop_mongrel_cluster.
|
113
|
+
DESC
|
114
|
+
task :stop, :roles => :app do
|
115
|
+
mongrel.cluster.stop
|
116
|
+
end
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
def set_mongrel_conf
|
121
|
+
set :mongrel_conf, "/etc/mongrel_cluster/#{application}.yml" unless mongrel_conf
|
122
|
+
end
|
123
|
+
|
124
|
+
def set_mongrel_pid_file
|
125
|
+
set :mongrel_pid_file, "/var/run/mongrel_cluster/#{application}.pid" unless mongrel_pid_file
|
126
|
+
end
|
127
|
+
end
|
@@ -20,28 +20,32 @@ module MySQLMethods
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
Capistrano.plugin :
|
23
|
+
Capistrano.plugin :mysql_helper, MySQLMethods
|
24
24
|
|
25
|
-
Capistrano.
|
25
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
26
26
|
|
27
27
|
set :mysql_admin, nil
|
28
28
|
|
29
|
-
|
30
|
-
task :execute_mysql, :roles => :db, :only => { :primary => true } do
|
31
|
-
set_mysql_admin
|
32
|
-
mysql.execute sql, mysql_admin
|
33
|
-
end
|
29
|
+
namespace :mysql do
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
read_config
|
31
|
+
desc "Execute MySQL statements using --execute option. Set the 'sql' variable."
|
32
|
+
task :execute, :roles => :db, :only => { :primary => true } do
|
33
|
+
set_mysql_admin
|
34
|
+
mysql_helper.execute sql, mysql_admin
|
35
|
+
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
37
|
+
desc "Create MySQL database and user based on config/database.yml"
|
38
|
+
task :setup, :roles => :db, :only => { :primary => true } do
|
39
|
+
# on_rollback {}
|
40
|
+
|
41
|
+
set_mysql_admin
|
42
|
+
read_config
|
43
|
+
|
44
|
+
sql = "CREATE DATABASE #{db_name};"
|
45
|
+
sql += "GRANT ALL PRIVILEGES ON #{db_name}.* TO #{db_user}@localhost IDENTIFIED BY '#{db_password}';"
|
46
|
+
mysql_helper.execute sql, mysql_admin
|
47
|
+
end
|
48
|
+
|
45
49
|
end
|
46
50
|
|
47
51
|
def read_config
|
@@ -55,4 +59,4 @@ Capistrano.configuration(:must_exist).load do
|
|
55
59
|
set :mysql_admin, user unless mysql_admin
|
56
60
|
end
|
57
61
|
|
58
|
-
end
|
62
|
+
end
|
@@ -1,8 +1,5 @@
|
|
1
|
-
#
|
2
|
-
#
|
3
|
-
|
4
|
-
# CentOS 4.3 install for Rails Machine
|
5
|
-
# sudo -s
|
1
|
+
# CentOS install for Rails Machine
|
2
|
+
# sudo su -
|
6
3
|
# yum install postgresql-client postgresql-server postgresql-devel
|
7
4
|
# chkconfig postgresql on
|
8
5
|
# service postgresql start
|
@@ -41,19 +38,18 @@ end
|
|
41
38
|
|
42
39
|
Capistrano.plugin :pgsql, PostgreSQLMethods
|
43
40
|
|
44
|
-
Capistrano.
|
41
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
45
42
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
43
|
+
namespace :postgresql do
|
44
|
+
|
45
|
+
desc "Create PosgreSQL database and user based on config/database.yml"
|
46
|
+
task :setup, :roles => :db, :only => { :primary => true } do
|
47
|
+
# on_rollback {} TODO
|
48
|
+
read_config
|
49
|
+
pgsql.createuser db_user, db_password
|
50
|
+
pgsql.createdb db_name, db_user
|
51
|
+
end
|
53
52
|
|
54
|
-
desc "Setup database"
|
55
|
-
task :setup_db, :roles => :db, :only => { :primary => true } do
|
56
|
-
setup_pgsql
|
57
53
|
end
|
58
54
|
|
59
55
|
def read_config
|
@@ -63,4 +59,4 @@ Capistrano.configuration(:must_exist).load do
|
|
63
59
|
set :db_name, db_config[rails_env]["database"]
|
64
60
|
end
|
65
61
|
|
66
|
-
end
|
62
|
+
end
|
@@ -1,42 +1,46 @@
|
|
1
1
|
require 'fileutils'
|
2
|
-
Capistrano.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
namespace :svn do
|
5
|
+
|
6
|
+
desc "Setup svn repository"
|
7
|
+
task :setup, :roles => :scm do
|
8
|
+
dir = "#{deploy_to}/repos"
|
9
|
+
run "mkdir -p #{dir}"
|
10
|
+
run "chmod 770 #{dir}"
|
11
|
+
run "svnadmin create #{dir}"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Import code into svn repository."
|
15
|
+
task :import do
|
16
|
+
new_path = Dir.pwd + "_machine"
|
17
|
+
tags = repository.sub("trunk", "tags")
|
18
|
+
branches = repository.sub("trunk", "branches")
|
19
|
+
puts "Adding branches and tags"
|
20
|
+
system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
|
21
|
+
puts "Importing application."
|
22
|
+
system "svn import #{repository} -m 'Import'"
|
23
|
+
puts "Checking out to new directory."
|
24
|
+
system "svn co #{repository} #{new_path}"
|
25
|
+
cwd = Dir.getwd
|
26
|
+
Dir.chdir new_path
|
27
|
+
puts "removing log directory contents from svn"
|
28
|
+
system "svn remove log/*"
|
29
|
+
puts "ignoring log directory"
|
30
|
+
system "svn propset svn:ignore '*.log' log/"
|
31
|
+
system "svn update log/"
|
32
|
+
puts "removing tmp directory from svn"
|
33
|
+
system "svn remove tmp/"
|
34
|
+
puts "ignoring tmp directory"
|
35
|
+
system "svn propset svn:ignore '*' tmp/"
|
36
|
+
system "svn update tmp/"
|
37
|
+
puts "committing changes"
|
38
|
+
system "svn commit -m 'Removed and ignored log files and tmp'"
|
39
|
+
Dir.chdir cwd
|
40
|
+
puts "Your repository is: #{repository}"
|
41
|
+
puts "Please change to your new working directory: #{new_path}"
|
42
|
+
end
|
11
43
|
|
12
|
-
desc "Import code into svn repository."
|
13
|
-
task :import_svn do
|
14
|
-
new_path = Dir.pwd + "_machine"
|
15
|
-
tags = repository.sub("trunk", "tags")
|
16
|
-
branches = repository.sub("trunk", "branches")
|
17
|
-
puts "Adding branches and tags"
|
18
|
-
system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
|
19
|
-
puts "Importing application."
|
20
|
-
system "svn import #{repository} -m 'Import'"
|
21
|
-
puts "Checking out to new directory."
|
22
|
-
system "svn co #{repository} #{new_path}"
|
23
|
-
cwd = Dir.getwd
|
24
|
-
Dir.chdir new_path
|
25
|
-
puts "removing log directory contents from svn"
|
26
|
-
system "svn remove log/*"
|
27
|
-
puts "ignoring log directory"
|
28
|
-
system "svn propset svn:ignore '*.log' log/"
|
29
|
-
system "svn update log/"
|
30
|
-
puts "removing tmp directory from svn"
|
31
|
-
system "svn remove tmp/"
|
32
|
-
puts "ignoring tmp directory"
|
33
|
-
system "svn propset svn:ignore '*' tmp/"
|
34
|
-
system "svn update tmp/"
|
35
|
-
puts "committing changes"
|
36
|
-
system "svn commit -m 'Removed and ignored log files and tmp'"
|
37
|
-
Dir.chdir cwd
|
38
|
-
puts "Your repository is: #{repository}"
|
39
|
-
puts "Please change to your new working directory: #{new_path}"
|
40
44
|
end
|
41
45
|
|
42
46
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.4
|
3
3
|
specification_version: 1
|
4
4
|
name: railsmachine
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 1.0.0
|
7
|
+
date: 2007-11-02 00:00:00 -04:00
|
8
8
|
summary: The Rails Machine task library
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -27,7 +27,7 @@ signing_key:
|
|
27
27
|
cert_chain:
|
28
28
|
post_install_message:
|
29
29
|
authors:
|
30
|
-
- Bradley Taylor
|
30
|
+
- Bradley Taylor, Rob Lingle
|
31
31
|
files:
|
32
32
|
- COPYING
|
33
33
|
- LICENSE
|
@@ -36,22 +36,22 @@ files:
|
|
36
36
|
- bin/railsmachine
|
37
37
|
- lib/railsmachine
|
38
38
|
- lib/railsmachine/generators
|
39
|
-
- lib/railsmachine/recipes
|
40
|
-
- lib/railsmachine/recipes.rb
|
41
39
|
- lib/railsmachine/generators/loader.rb
|
42
40
|
- lib/railsmachine/generators/railsmachine
|
43
|
-
- lib/railsmachine/generators/railsmachine/railsmachine_generator.rb
|
44
41
|
- lib/railsmachine/generators/railsmachine/templates
|
45
|
-
- lib/railsmachine/generators/railsmachine/USAGE
|
46
42
|
- lib/railsmachine/generators/railsmachine/templates/deploy.rb
|
47
|
-
- lib/railsmachine/
|
48
|
-
- lib/railsmachine/
|
49
|
-
- lib/railsmachine/recipes
|
50
|
-
- lib/railsmachine/recipes
|
51
|
-
- lib/railsmachine/recipes/svn.rb
|
43
|
+
- lib/railsmachine/generators/railsmachine/railsmachine_generator.rb
|
44
|
+
- lib/railsmachine/generators/railsmachine/USAGE
|
45
|
+
- lib/railsmachine/recipes.rb
|
46
|
+
- lib/railsmachine/recipes
|
52
47
|
- lib/railsmachine/recipes/templates
|
53
|
-
- lib/railsmachine/recipes/templates/httpd-ssl.conf
|
54
48
|
- lib/railsmachine/recipes/templates/httpd.conf
|
49
|
+
- lib/railsmachine/recipes/templates/httpd-ssl.conf
|
50
|
+
- lib/railsmachine/recipes/pgsql.rb
|
51
|
+
- lib/railsmachine/recipes/mysql.rb
|
52
|
+
- lib/railsmachine/recipes/svn.rb
|
53
|
+
- lib/railsmachine/recipes/mongrel.rb
|
54
|
+
- lib/railsmachine/recipes/apache.rb
|
55
55
|
- tools/rakehelp.rb
|
56
56
|
- resources/defaults.yaml
|
57
57
|
test_files: []
|
@@ -74,14 +74,5 @@ dependencies:
|
|
74
74
|
requirements:
|
75
75
|
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
|
-
version:
|
78
|
-
version:
|
79
|
-
- !ruby/object:Gem::Dependency
|
80
|
-
name: mongrel_cluster
|
81
|
-
version_requirement:
|
82
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
83
|
-
requirements:
|
84
|
-
- - ">="
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
version: 0.2.0
|
77
|
+
version: 2.0.0
|
87
78
|
version:
|