centostrano 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/docs/offline_installation.txt +16 -0
- data/lib/deprec/capistrano_extensions.rb +60 -16
- data/lib/deprec/recipes.rb +1 -0
- data/lib/deprec/recipes/apache.rb +8 -6
- data/lib/deprec/recipes/gitosis.rb +21 -1
- data/lib/deprec/recipes/merb.rb +2 -2
- data/lib/deprec/recipes/mongrel.rb +11 -6
- data/lib/deprec/recipes/mysql.rb +5 -5
- data/lib/deprec/recipes/nginx.rb +23 -19
- data/lib/deprec/recipes/passenger.rb +127 -0
- data/lib/deprec/recipes/rails.rb +15 -25
- data/lib/deprec/recipes/ruby.rb +8 -8
- data/lib/deprec/recipes/sphinx.rb +3 -0
- data/lib/deprec/recipes/svn.rb +1 -1
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +1 -1
- data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
- data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +1 -1
- data/lib/deprec/templates/nginx/nginx.conf.erb +14 -4
- data/lib/deprec/templates/passenger/apache_vhost.erb +10 -0
- data/lib/deprec/templates/passenger/passenger.erb +20 -0
- data/lib/deprec/templates/ssh/ssh_config.erb +1 -1
- metadata +121 -117
- data/lib/deprec/templates/coraid/aoe-init +0 -55
- data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +0 -14
@@ -0,0 +1,16 @@
|
|
1
|
+
Using deprec offline (on a plane!)
|
2
|
+
==================================
|
3
|
+
|
4
|
+
# Run local rubygems server
|
5
|
+
- point gems.rubyforge.org at local gems server
|
6
|
+
|
7
|
+
# Turn off network apt sources and enable cdrom
|
8
|
+
- use apt-cdrom
|
9
|
+
|
10
|
+
# Run local apt mirror (optional)
|
11
|
+
|
12
|
+
# Push sources for compiled packages to target(s)
|
13
|
+
cap deprec:find_src
|
14
|
+
cap deprec:push_src
|
15
|
+
|
16
|
+
|
@@ -4,12 +4,24 @@ require 'fileutils'
|
|
4
4
|
|
5
5
|
module Deprec2
|
6
6
|
|
7
|
-
#
|
7
|
+
# Temporarily modify ROLES if HOSTS not set
|
8
|
+
# Capistrano's default behaviour is for HOSTS to override ROLES
|
8
9
|
def for_roles(roles)
|
9
10
|
old_roles = ENV['ROLES']
|
10
|
-
ENV['ROLES'] = roles
|
11
|
+
ENV['ROLES'] = roles.to_s unless ENV['HOSTS']
|
12
|
+
yield
|
13
|
+
ENV['ROLES'] = old_roles.to_s unless ENV['HOSTS']
|
14
|
+
end
|
15
|
+
|
16
|
+
# Temporarily ignore ROLES and HOSTS
|
17
|
+
def ignoring_roles_and_hosts
|
18
|
+
old_roles = ENV['ROLES']
|
19
|
+
old_hosts = ENV['HOSTS']
|
20
|
+
ENV['ROLES'] = nil
|
21
|
+
ENV['HOSTS'] = nil
|
11
22
|
yield
|
12
23
|
ENV['ROLES'] = old_roles
|
24
|
+
ENV['HOSTS'] = old_hosts
|
13
25
|
end
|
14
26
|
|
15
27
|
DEPREC_TEMPLATES_BASE = File.join(File.dirname(__FILE__), 'templates')
|
@@ -242,35 +254,67 @@ module Deprec2
|
|
242
254
|
if defined?(src_package[:md5sum])
|
243
255
|
md5_clause = " && echo '#{src_package[:md5sum]}' | md5sum -c - "
|
244
256
|
end
|
245
|
-
|
246
|
-
|
247
|
-
|
257
|
+
case src_package[:download_method]
|
258
|
+
# when getting source with git
|
259
|
+
when :git
|
260
|
+
# ensure git is installed
|
261
|
+
apt.install( {:base => %w(git)}, :stable) #TODO fix this to test ubuntu version <hardy might need specific git version for full git submodules support
|
262
|
+
package_dir = File.join(src_dir, src_package[:dir])
|
263
|
+
run "if [ -d #{package_dir} ]; then cd #{package_dir} && #{sudo} git checkout master && #{sudo} git pull && #{sudo} git submodule init && #{sudo} git submodule update; else #{sudo} git clone #{src_package[:url]} #{package_dir} && cd #{package_dir} && #{sudo} git submodule init && #{sudo} git submodule update ; fi"
|
264
|
+
# Checkout the revision wanted if defined
|
265
|
+
if src_package[:version]
|
266
|
+
run "cd #{package_dir} && git branch | grep '#{src_package[:version]}$' && #{sudo} git branch -D '#{src_package[:version]}'; exit 0"
|
267
|
+
run "cd #{package_dir} && #{sudo} git checkout -b #{src_package[:version]} #{src_package[:version]}"
|
268
|
+
end
|
269
|
+
|
270
|
+
# when getting source with wget
|
271
|
+
when :http
|
272
|
+
# ensure wget is installed
|
273
|
+
apt.install( {:base => %w(wget)}, :stable )
|
274
|
+
# XXX replace with invoke_command
|
275
|
+
run "cd #{src_dir} && test -f #{src_package[:filename]} #{md5_clause} || #{sudo} wget --quiet --timestamping #{src_package[:url]}"
|
276
|
+
else
|
277
|
+
puts "DOWNLOAD SRC: Download method not recognised. src_package[:download_method]: #{src_package[:download_method]}"
|
278
|
+
end
|
248
279
|
end
|
249
280
|
|
250
281
|
# unpack src and make it writable by the group
|
251
282
|
def unpack_src(src_package, src_dir)
|
252
283
|
set_package_defaults(src_package)
|
253
284
|
package_dir = File.join(src_dir, src_package[:dir])
|
254
|
-
|
285
|
+
case src_package[:download_method]
|
286
|
+
# when unpacking git sources - nothing to do
|
287
|
+
when :git
|
288
|
+
puts "UNPACK SRC: nothing to do for git installs"
|
289
|
+
when :http
|
290
|
+
sudo <<-EOF
|
291
|
+
bash -c '
|
292
|
+
cd #{src_dir};
|
293
|
+
test -d #{package_dir}.old && rm -fr #{package_dir}.old;
|
294
|
+
test -d #{package_dir} && mv #{package_dir} #{package_dir}.old;
|
295
|
+
#{src_package[:unpack]}
|
296
|
+
'
|
297
|
+
EOF
|
298
|
+
else
|
299
|
+
puts "UNPACK SRC: Download method not recognised. src_package[:download_method]: #{src_package[:download_method]} "
|
300
|
+
end
|
255
301
|
sudo <<-EOF
|
256
302
|
bash -c '
|
257
303
|
cd #{src_dir};
|
258
|
-
test -d #{package_dir}.old && rm -fr #{package_dir}.old;
|
259
|
-
test -d #{package_dir} && mv #{package_dir} #{package_dir}.old;
|
260
|
-
#{src_package[:unpack]}
|
261
304
|
chgrp -R #{group} #{package_dir};
|
262
305
|
chmod -R g+w #{package_dir};
|
263
306
|
'
|
264
307
|
EOF
|
265
308
|
end
|
266
|
-
|
309
|
+
|
267
310
|
def set_package_defaults(pkg)
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
311
|
+
pkg[:filename] ||= File.basename(pkg[:url])
|
312
|
+
pkg[:dir] ||= pkg[:filename].sub(/(\.tgz|\.tar\.gz)/,'')
|
313
|
+
pkg[:download_method] ||= :http
|
314
|
+
pkg[:unpack] ||= "tar zxf #{pkg[:filename]};"
|
315
|
+
pkg[:configure] ||= './configure ;'
|
316
|
+
pkg[:make] ||= 'make;'
|
317
|
+
pkg[:install] ||= 'make install;'
|
274
318
|
end
|
275
319
|
|
276
320
|
# install package from source
|
data/lib/deprec/recipes.rb
CHANGED
@@ -31,3 +31,4 @@ require "#{File.dirname(__FILE__)}/recipes/gitosis"
|
|
31
31
|
require "#{File.dirname(__FILE__)}/recipes/postgresql"
|
32
32
|
require "#{File.dirname(__FILE__)}/recipes/logrotate"
|
33
33
|
require "#{File.dirname(__FILE__)}/recipes/merb"
|
34
|
+
require "#{File.dirname(__FILE__)}/recipes/passenger"
|
@@ -38,11 +38,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
38
38
|
|
39
39
|
|
40
40
|
SRC_PACKAGES[:apache] = {
|
41
|
-
:filename => 'httpd-2.2.
|
42
|
-
:md5sum => "
|
43
|
-
:dir => 'httpd-2.2.
|
44
|
-
:url => "http://www.apache.org/dist/httpd/httpd-2.2.
|
45
|
-
:unpack => "tar zxf httpd-2.2.
|
41
|
+
:filename => 'httpd-2.2.11.tar.gz',
|
42
|
+
:md5sum => "03e0a99a5de0f3f568a0087fb9993af9 httpd-2.2.11.tar.gz",
|
43
|
+
:dir => 'httpd-2.2.11',
|
44
|
+
:url => "http://www.apache.org/dist/httpd/httpd-2.2.11.tar.gz",
|
45
|
+
:unpack => "tar zxf httpd-2.2.11.tar.gz;",
|
46
46
|
:configure => %w(
|
47
47
|
./configure
|
48
48
|
--enable-mods-shared=all
|
@@ -62,7 +62,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
62
62
|
:make => 'make;',
|
63
63
|
:install => '--fstrans=no make install;',
|
64
64
|
:post_install => 'install -b support/apachectl /etc/init.d/httpd;',
|
65
|
-
:version => 'c2.2.
|
65
|
+
:version => 'c2.2.11',
|
66
66
|
:release => '1'
|
67
67
|
}
|
68
68
|
|
@@ -159,6 +159,8 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
159
159
|
|
160
160
|
desc "Set apache to start on boot"
|
161
161
|
task :activate do
|
162
|
+
send(run_method, "sed -i '2i# chkconfig: 2345 10 90' /etc/init.d/httpd")
|
163
|
+
send(run_method, "sed -i '3i# description: Activates/Deactivates Apache Web Server' /etc/init.d/httpd")
|
162
164
|
send(run_method, "/sbin/chkconfig --add httpd")
|
163
165
|
send(run_method, "/sbin/chkconfig --level 345 httpd on")
|
164
166
|
end
|
@@ -129,6 +129,26 @@ members = #{gitosis_admin} #{gitosis_server}
|
|
129
129
|
system "git add ."
|
130
130
|
system "git commit -a -m 'Touched .gitignore to emtpy folders, ignored log files, tmp, sqlite3 db'"
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
|
+
desc "setup \"external\" repository accessible to redmine"
|
134
|
+
task :setup_for_redmine do
|
135
|
+
sudo "test -d /var/git/checkout || sudo mkdir -p /var/git/checkout"
|
136
|
+
sudo "test -d /var/git/checkout/#{application} || sudo git clone /home/git/repositories/#{application}.git /var/git/checkout/#{application}"
|
137
|
+
sudo "chown -R git:deploy /var/git/checkout/#{application}"
|
138
|
+
hook_file = "/home/git/repositories/#{application}.git/hooks/post-update"
|
139
|
+
hook_file_tmp = "/tmp/hook_file.tmp"
|
140
|
+
sudo "echo \"#!/bin/sh\" > #{hook_file_tmp}"
|
141
|
+
[
|
142
|
+
"cd /var/git/checkout/#{application} || exit",
|
143
|
+
"unset GIT_DIR",
|
144
|
+
"git pull /home/git/repositories/#{application}.git/ master",
|
145
|
+
"exec git-update-server-info"
|
146
|
+
].each { |l| sudo "echo \"#{l}\" >> #{hook_file_tmp}" }
|
147
|
+
sudo "mv #{hook_file_tmp} #{hook_file}"
|
148
|
+
sudo "chmod 755 #{hook_file}"
|
149
|
+
sudo "chown git:scm #{hook_file}"
|
150
|
+
puts "\nPut '/var/git/checkout/#{application}/.git' into Redmine Git repository settings\n\n"
|
151
|
+
end
|
152
|
+
|
133
153
|
end end
|
134
154
|
end
|
data/lib/deprec/recipes/merb.rb
CHANGED
@@ -16,7 +16,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
16
16
|
desc "Install merb"
|
17
17
|
task :install, :roles => :app do
|
18
18
|
install_deps
|
19
|
-
%w(core plugins
|
19
|
+
%w(extlib core more plugins).each do |gem|
|
20
20
|
package_info = {
|
21
21
|
:filename => "merb-#{gem}",
|
22
22
|
:dir => "merb-#{gem}",
|
@@ -30,7 +30,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
30
30
|
task :install_deps do
|
31
31
|
top.centos.mongrel.install
|
32
32
|
top.centos.git.install
|
33
|
-
gem2.install(%w(rack mongrel json json_pure erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory ruby2ruby))
|
33
|
+
gem2.install(%w(rack mongrel json json_pure erubis mime-types rspec hpricot mocha rubigen haml markaby mailfactory ruby2ruby facets))
|
34
34
|
end
|
35
35
|
|
36
36
|
|
@@ -21,7 +21,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
21
21
|
# Install
|
22
22
|
|
23
23
|
desc "Install mongrel"
|
24
|
-
task :install do
|
24
|
+
task :install, :roles => :app do
|
25
25
|
gem2.install 'mongrel'
|
26
26
|
gem2.install 'mongrel_cluster'
|
27
27
|
gem2.install 'swiftiply'
|
@@ -32,7 +32,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
32
32
|
activate_system
|
33
33
|
end
|
34
34
|
|
35
|
-
task :symlink_mongrel_rails do
|
35
|
+
task :symlink_mongrel_rails, :roles => :app do
|
36
36
|
sudo "ln -sf /usr/local/bin/mongrel_rails /usr/bin/mongrel_rails"
|
37
37
|
end
|
38
38
|
|
@@ -136,23 +136,28 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
136
136
|
task :stop, :roles => :app do
|
137
137
|
send(run_method, "mongrel_rails cluster::stop -C #{mongrel_conf}")
|
138
138
|
end
|
139
|
+
|
140
|
+
desc "Stop all mongrel clusters."
|
141
|
+
task :stop_all, :roles => :app do
|
142
|
+
run "#{sudo} /etc/init.d/mongrel_cluster stop"
|
143
|
+
end
|
139
144
|
|
140
145
|
desc "Restart application server."
|
141
146
|
task :restart, :roles => :app do
|
142
147
|
send(run_method, "mongrel_rails cluster::restart --clean -C #{mongrel_conf}")
|
143
148
|
end
|
144
149
|
|
145
|
-
task :activate
|
150
|
+
task :activate do
|
146
151
|
activate_system
|
147
152
|
activate_project
|
148
153
|
end
|
149
154
|
|
150
|
-
task :activate_system
|
155
|
+
task :activate_system do
|
151
156
|
send(run_method, "/sbin/chkconfig --add mongrel_cluster")
|
152
|
-
send(run_method, "/sbin/chkconfig --level
|
157
|
+
send(run_method, "/sbin/chkconfig --level 35 mongrel_cluster on")
|
153
158
|
end
|
154
159
|
|
155
|
-
task :activate_project
|
160
|
+
task :activate_project do
|
156
161
|
symlink_mongrel_cluster
|
157
162
|
symlink_monit_config
|
158
163
|
end
|
data/lib/deprec/recipes/mysql.rb
CHANGED
@@ -8,7 +8,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
8
8
|
desc "Install mysql"
|
9
9
|
task :install, :roles => :db do
|
10
10
|
install_deps
|
11
|
-
symlink_mysql_sockfile # XXX still needed?
|
11
|
+
#symlink_mysql_sockfile # XXX still needed?
|
12
12
|
end
|
13
13
|
|
14
14
|
# Install dependencies for Mysql
|
@@ -23,12 +23,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
23
23
|
execute(sql, db_user)
|
24
24
|
end
|
25
25
|
|
26
|
-
task :symlink_mysql_sockfile, :roles => :db do
|
26
|
+
#task :symlink_mysql_sockfile, :roles => :db do
|
27
27
|
# rails puts "socket: /tmp/mysql.sock" into config/database.yml
|
28
28
|
# this is not the location for our ubuntu's mysql socket file
|
29
29
|
# so we create this link to make deployment using rails defaults simpler
|
30
|
-
|
31
|
-
end
|
30
|
+
# sudo "ln -sf /var/lib/mysql/mysql.sock /tmp/mysql.sock"
|
31
|
+
#end
|
32
32
|
|
33
33
|
# Configuration
|
34
34
|
|
@@ -54,7 +54,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
desc "Push
|
57
|
+
desc "Push mysql config files to server"
|
58
58
|
task :config, :roles => :db do
|
59
59
|
deprec2.push_configs(:mysql, SYSTEM_CONFIG_FILES[:mysql])
|
60
60
|
end
|
data/lib/deprec/recipes/nginx.rb
CHANGED
@@ -7,14 +7,15 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
7
7
|
set :nginx_user, 'nginx'
|
8
8
|
set :nginx_group, 'nginx'
|
9
9
|
set :nginx_vhost_dir, '/usr/local/nginx/conf/vhosts'
|
10
|
-
set :nginx_client_max_body_size, '
|
10
|
+
set :nginx_client_max_body_size, '100M'
|
11
|
+
set :nginx_worker_processes, 4
|
11
12
|
|
12
13
|
SRC_PACKAGES[:nginx] = {
|
13
|
-
:filename => 'nginx-0.6.
|
14
|
-
:md5sum => "
|
15
|
-
:dir => 'nginx-0.6.
|
16
|
-
:url => "http://sysoev.ru/nginx/nginx-0.6.
|
17
|
-
:unpack => "tar zxf nginx-0.6.
|
14
|
+
:filename => 'nginx-0.6.34.tar.gz',
|
15
|
+
:md5sum => "837bcfb88bdc6b6efc4e63979c9c7b41 nginx-0.6.34.tar.gz",
|
16
|
+
:dir => 'nginx-0.6.34',
|
17
|
+
:url => "http://sysoev.ru/nginx/nginx-0.6.34.tar.gz",
|
18
|
+
:unpack => "tar zxf nginx-0.6.34.tar.gz;",
|
18
19
|
:configure => %w(
|
19
20
|
./configure
|
20
21
|
--sbin-path=/usr/local/sbin
|
@@ -23,12 +24,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
23
24
|
).reject{|arg| arg.match '#'}.join(' '),
|
24
25
|
:make => 'make;',
|
25
26
|
:install => 'make install;',
|
26
|
-
:version => 'c0.6.
|
27
|
+
:version => 'c0.6.34',
|
27
28
|
:release => '1'
|
28
29
|
}
|
29
30
|
|
30
31
|
desc "Install nginx"
|
31
|
-
task :install do
|
32
|
+
task :install, :roles => :web do
|
32
33
|
install_deps
|
33
34
|
deprec2.download_src(SRC_PACKAGES[:nginx], src_dir)
|
34
35
|
yum.install_from_src(SRC_PACKAGES[:nginx], src_dir)
|
@@ -43,22 +44,18 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
43
44
|
end
|
44
45
|
|
45
46
|
# install dependencies for nginx
|
46
|
-
task :install_deps do
|
47
|
+
task :install_deps, :roles => :web do
|
47
48
|
#apt.install( {:base => %w(libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev)}, :stable )
|
48
49
|
apt.install( {:base => %w(pcre* openssl openssl-devel zlib-devel)}, :stable )
|
49
50
|
# do we need libgcrypt11-dev?
|
50
51
|
end
|
51
52
|
|
52
|
-
task :create_nginx_user do
|
53
|
+
task :create_nginx_user, :roles => :web do
|
53
54
|
deprec2.groupadd(nginx_group)
|
54
55
|
deprec2.useradd(nginx_user, :group => nginx_group, :homedir => false)
|
55
56
|
end
|
56
57
|
|
57
|
-
|
58
|
-
index_file = '/usr/local/nginx/html/index.html'
|
59
|
-
sudo "test -f #{index_file} && sudo mv #{index_file} #{index_file}.orig || exit 0"
|
60
|
-
end
|
61
|
-
|
58
|
+
|
62
59
|
SYSTEM_CONFIG_FILES[:nginx] = [
|
63
60
|
|
64
61
|
{:template => 'nginx-init-script',
|
@@ -116,11 +113,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
116
113
|
Activate nginx start scripts on server.
|
117
114
|
Setup server to start nginx on boot.
|
118
115
|
DESC
|
119
|
-
task :activate do
|
116
|
+
task :activate, :roles => :web do
|
120
117
|
activate_system
|
121
118
|
end
|
122
119
|
|
123
|
-
task :activate_system do
|
120
|
+
task :activate_system, :roles => :web do
|
124
121
|
send(run_method, "/sbin/chkconfig --add nginx")
|
125
122
|
send(run_method, "/sbin/chkconfig --level 345 nginx on")
|
126
123
|
end
|
@@ -129,7 +126,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
129
126
|
Dectivate nginx start scripts on server.
|
130
127
|
Setup server to start nginx on boot.
|
131
128
|
DESC
|
132
|
-
task :deactivate do
|
129
|
+
task :deactivate, :roles => :web do
|
133
130
|
send(run_method, "/sbin/chkconfig --del nginx")
|
134
131
|
end
|
135
132
|
|
@@ -143,7 +140,9 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
143
140
|
|
144
141
|
desc "Stop Nginx"
|
145
142
|
task :stop, :roles => :web do
|
146
|
-
|
143
|
+
# Nginx returns error code if you try to stop when it's not running
|
144
|
+
# We don't want this to kill Capistrano.
|
145
|
+
send(run_method, "/etc/init.d/nginx stop; exit 0")
|
147
146
|
end
|
148
147
|
|
149
148
|
desc "Restart Nginx"
|
@@ -167,6 +166,11 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
167
166
|
# there's nothing to store for nginx
|
168
167
|
end
|
169
168
|
|
169
|
+
# Helper task to get rid of pesky "it works" page - not called by deprec tasks
|
170
|
+
task :rename_index_page, :roles => :web do
|
171
|
+
index_file = '/usr/local/nginx/html/index.html'
|
172
|
+
sudo "test -f #{index_file} && sudo mv #{index_file} #{index_file}.orig || exit 0"
|
173
|
+
end
|
170
174
|
end
|
171
175
|
end
|
172
176
|
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :centos do
|
4
|
+
namespace :passenger do
|
5
|
+
|
6
|
+
set :passenger_install_dir, '/opt/passenger'
|
7
|
+
set(:passenger_document_root) { "#{current_path}/public" }
|
8
|
+
set :passenger_rails_allow_mod_rewrite, 'off'
|
9
|
+
set :passenger_vhost_dir, '/usr/local/apache2/conf/apps'
|
10
|
+
# Default settings for Passenger config files
|
11
|
+
set :passenger_log_level, 0
|
12
|
+
set :passenger_user_switching, 'on'
|
13
|
+
set :passenger_default_user, 'nobody'
|
14
|
+
set :passenger_max_pool_size, 6
|
15
|
+
set :passenger_max_instances_per_app, 0
|
16
|
+
set :passenger_pool_idle_time, 300
|
17
|
+
set :passenger_rails_autodetect, 'on'
|
18
|
+
set :passenger_rails_spawn_method, 'smart' # smart | conservative
|
19
|
+
|
20
|
+
SRC_PACKAGES[:passenger] = {
|
21
|
+
:url => "git://github.com/FooBarWidget/passenger.git",
|
22
|
+
:download_method => :git,
|
23
|
+
:version => 'release-2.0.6', # Specify a tagged release to deploy
|
24
|
+
:configure => '',
|
25
|
+
:make => '',
|
26
|
+
:install => ' ./bin/passenger-install-apache2-module'
|
27
|
+
}
|
28
|
+
|
29
|
+
SYSTEM_CONFIG_FILES[:passenger] = [
|
30
|
+
|
31
|
+
{:template => 'passenger.erb',
|
32
|
+
:path => '/usr/local/apache2/conf/apps/passenger',
|
33
|
+
:mode => 0755,
|
34
|
+
:owner => 'root:root'}
|
35
|
+
|
36
|
+
]
|
37
|
+
|
38
|
+
PROJECT_CONFIG_FILES[:passenger] = [
|
39
|
+
|
40
|
+
{ :template => 'apache_vhost.erb',
|
41
|
+
:path => 'apache_vhost',
|
42
|
+
:mode => 0755,
|
43
|
+
:owner => 'root:root'}
|
44
|
+
|
45
|
+
]
|
46
|
+
|
47
|
+
desc "Install passenger"
|
48
|
+
task :install, :roles => :passenger do
|
49
|
+
install_deps
|
50
|
+
deprec2.download_src(SRC_PACKAGES[:passenger], src_dir)
|
51
|
+
|
52
|
+
# Non standard - passenger requires input
|
53
|
+
package_dir = File.join(src_dir, 'passenger.git')
|
54
|
+
dest_dir = passenger_install_dir + '-' + (SRC_PACKAGES[:passenger][:version] || 'trunk')
|
55
|
+
run "#{sudo} rsync -avz #{package_dir}/ #{dest_dir}"
|
56
|
+
run <<-EOF
|
57
|
+
cd #{dest_dir} &&
|
58
|
+
#{sudo} ruby -i -pe '$_ = $_.sub("STDIN.readline","# do nothing")' bin/passenger-install-apache2-module
|
59
|
+
EOF
|
60
|
+
run "export APXS2=/usr/local/apache2/bin/apxs"
|
61
|
+
run "export APR_CONFIG=/usr/local/apache2/bin/apr-1-config"
|
62
|
+
sudo "su -c 'export PATH=/usr/local/apache2/bin:$PATH && export APXS2=/usr/local/apache2/bin/apxs && export APR_CONFIG=/usr/local/apache2/bin/apr-1-config && cd #{dest_dir} && ./bin/passenger-install-apache2-module'"
|
63
|
+
#run "cd #{dest_dir} && #{sudo} ./bin/passenger-install-apache2-module"
|
64
|
+
run "#{sudo} unlink #{passenger_install_dir} 2>/dev/null; #{sudo} ln -sf #{dest_dir} #{passenger_install_dir}"
|
65
|
+
end
|
66
|
+
|
67
|
+
# install dependencies for nginx
|
68
|
+
task :install_deps, :roles => :passenger do
|
69
|
+
apt.install( {:base => %w(rsync apr-devel)}, :stable )
|
70
|
+
gem2.install 'rack'
|
71
|
+
top.centos.apache.install
|
72
|
+
end
|
73
|
+
|
74
|
+
desc "Generate Passenger apache configs (system & project level)."
|
75
|
+
task :config_gen do
|
76
|
+
config_gen_system
|
77
|
+
config_gen_project
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Generate Passenger apache configs (system level) from template."
|
81
|
+
task :config_gen_system do
|
82
|
+
SYSTEM_CONFIG_FILES[:passenger].each do |file|
|
83
|
+
deprec2.render_template(:passenger, file)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Generate Passenger apache configs (project level) from template."
|
88
|
+
task :config_gen_project do
|
89
|
+
PROJECT_CONFIG_FILES[:passenger].each do |file|
|
90
|
+
deprec2.render_template(:passenger, file)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "Push Passenger config files (system & project level) to server"
|
95
|
+
task :config, :roles => :passenger do
|
96
|
+
config_system
|
97
|
+
config_project
|
98
|
+
end
|
99
|
+
|
100
|
+
desc "Push Passenger configs (system level) to server"
|
101
|
+
task :config_system, :roles => :passenger do
|
102
|
+
deprec2.push_configs(:passenger, SYSTEM_CONFIG_FILES[:passenger])
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "Push Passenger configs (project level) to server"
|
106
|
+
task :config_project, :roles => :passenger do
|
107
|
+
deprec2.push_configs(:passenger, PROJECT_CONFIG_FILES[:passenger])
|
108
|
+
symlink_passenger_vhost
|
109
|
+
end
|
110
|
+
|
111
|
+
task :symlink_passenger_vhost, :roles => :passenger do
|
112
|
+
sudo "ln -sf #{deploy_to}/passenger/apache_vhost #{passenger_vhost_dir}/#{application}.conf"
|
113
|
+
end
|
114
|
+
|
115
|
+
desc "Restart Application"
|
116
|
+
task :restart, :roles => :app do
|
117
|
+
run "touch #{current_path}/tmp/restart.txt"
|
118
|
+
end
|
119
|
+
|
120
|
+
desc "Restart Apache"
|
121
|
+
task :restart_apache, :roles => :passenger do
|
122
|
+
run "#{sudo} /etc/init.d/httpd restart"
|
123
|
+
end
|
124
|
+
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|