capitate 0.3.5 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +10 -0
- data/Manifest.txt +3 -9
- data/lib/capitate.rb +14 -0
- data/lib/capitate/cap_ext/namespace.rb +34 -0
- data/lib/capitate/cap_ext/task_definition.rb +22 -0
- data/lib/capitate/task_node.rb +21 -1
- data/lib/capitate/version.rb +1 -1
- data/lib/recipes/active_record.rb +7 -36
- data/lib/recipes/backgroundrb.rb +4 -19
- data/lib/recipes/centos/backgroundjob.rb +5 -26
- data/lib/recipes/centos/backgroundrb.rb +2 -13
- data/lib/recipes/centos/centos.rb +4 -26
- data/lib/recipes/centos/imagemagick.rb +8 -9
- data/lib/recipes/centos/memcached.rb +12 -53
- data/lib/recipes/centos/merb.rb +7 -33
- data/lib/recipes/centos/mongrel_cluster.rb +15 -51
- data/lib/recipes/centos/monit.rb +10 -36
- data/lib/recipes/centos/mysql.rb +1 -10
- data/lib/recipes/centos/nginx.rb +14 -42
- data/lib/recipes/centos/ruby.rb +6 -15
- data/lib/recipes/centos/sphinx.rb +13 -36
- data/lib/recipes/docs.rb +2 -14
- data/lib/recipes/logrotated.rb +20 -40
- data/lib/recipes/memcached.rb +10 -41
- data/lib/recipes/merb.rb +3 -4
- data/lib/recipes/monit.rb +4 -23
- data/lib/recipes/monit/merb.rb +7 -12
- data/lib/recipes/monit/mysql.rb +3 -19
- data/lib/recipes/monit/nginx.rb +2 -16
- data/lib/recipes/monit/sphinx.rb +20 -11
- data/lib/recipes/mysql.rb +13 -53
- data/lib/recipes/nginx.rb +9 -65
- data/lib/recipes/rails.rb +0 -58
- data/lib/recipes/sphinx.rb +20 -46
- data/lib/recipes/sshd.rb +6 -15
- data/lib/recipes/syslogd.rb +3 -43
- data/lib/templates/backgroundjob/backgroundjob.initd.centos.erb +4 -4
- data/lib/templates/merb/merb-no-http.monitrc.erb +13 -0
- data/lib/templates/merb/merb.initd.centos.erb +3 -3
- metadata +5 -12
- data/docs/nginx.README +0 -12
- data/website/index.html +0 -154
- data/website/index.txt +0 -69
- data/website/javascripts/code_highlighter.js +0 -188
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/javascripts/ruby.js +0 -18
- data/website/stylesheets/screen.css +0 -265
- data/website/template.rhtml +0 -69
- data/website/template_recipe.rhtml +0 -44
data/lib/recipes/memcached.rb
CHANGED
@@ -3,49 +3,18 @@ namespace :memcached do
|
|
3
3
|
desc <<-DESC
|
4
4
|
Create memcached yaml in shared path.
|
5
5
|
|
6
|
-
<dl>
|
7
|
-
<dt>memcached_namespace</dt>
|
8
|
-
|
9
|
-
<dt>memcached_ttl</dt>
|
10
|
-
<dd class="default">Defaults to @3600@</dd>
|
11
|
-
|
12
|
-
<dt>memcached_readonly</dt>
|
13
|
-
<dd class="default">Defaults to @false@</dd>
|
14
|
-
|
15
|
-
<dt>memcached_urlencode</dt>
|
16
|
-
<dd class="default">Defaults to @false@</dd>
|
17
|
-
|
18
|
-
<dt>memcached_c_threshold</dt>
|
19
|
-
<dd class="default">Defaults to @10000@</dd>
|
20
|
-
|
21
|
-
<dt>memcached_compression</dt>
|
22
|
-
<dd class="default">Defaults to @true@</dd>
|
23
|
-
|
24
|
-
<dt>memcached_debug</dt>
|
25
|
-
<dd class="default">Defaults to @false@</dd>
|
26
|
-
|
27
|
-
<dt>memcached_servers</dt>
|
28
|
-
<dd class="default">Defaults to @[ "localhost:11211" ]@</dd>
|
29
|
-
|
30
|
-
<dt>memcached_yml_template</dt>
|
31
|
-
<dd class="default">Defaults to @"memcached/memcached.yml.erb"@</dd>
|
32
|
-
</dl>
|
33
|
-
|
34
6
|
"Source":#{link_to_source(__FILE__)}
|
35
7
|
DESC
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
fetch_or_default(:memcached_servers, [ "localhost:11211" ])
|
47
|
-
fetch_or_default(:memcached_yml_template, "memcached/memcached.yml.erb")
|
48
|
-
|
8
|
+
task_arg(:memcached_namespace, "Namespace")
|
9
|
+
task_arg(:memcached_ttl, "TTL in seconds", :default => 3600)
|
10
|
+
task_arg(:memcached_readonly, "Read only enabled", :default => false)
|
11
|
+
task_arg(:memcached_urlencode, "URL encode enabled", :default => false)
|
12
|
+
task_arg(:memcached_c_threshold, "C Threshold", :default => 10000)
|
13
|
+
task_arg(:memcached_compression, "Compression enabed", :default => true)
|
14
|
+
task_arg(:memcached_debug, "Debug enabled", :default => false)
|
15
|
+
task_arg(:memcached_servers, "List of servers", :default => ["localhost:11211"], :default_desc => "[\"localhost:11211\"]")
|
16
|
+
task_arg(:memcached_yml_template, "Memcached yml template", :default => "memcached/memcached.yml.erb")
|
17
|
+
task :setup do
|
49
18
|
put(memcached_yml_template, "#{shared_path}/config/memcached.yml")
|
50
19
|
end
|
51
20
|
|
data/lib/recipes/merb.rb
CHANGED
@@ -15,11 +15,10 @@ namespace :merb do
|
|
15
15
|
set :migrate_env, ""
|
16
16
|
set :migrate_target, :latest
|
17
17
|
DESC
|
18
|
+
task_arg(:rake, "Path to rake", :default => "rake")
|
19
|
+
task_arg(:merb_env, "Merb environment", :default => "")
|
20
|
+
task_arg(:migrate_target, "Migration target", :default => :latest)
|
18
21
|
task :migrate, :roles => :db, :only => { :primary => true } do
|
19
|
-
rake = fetch(:rake, "rake")
|
20
|
-
merb_env = fetch(:merb_env, "production")
|
21
|
-
migrate_env = fetch(:migrate_env, "")
|
22
|
-
migrate_target = fetch(:migrate_target, :latest)
|
23
22
|
|
24
23
|
current_directory = case migrate_target.to_sym
|
25
24
|
when :current then current_path
|
data/lib/recipes/monit.rb
CHANGED
@@ -5,49 +5,30 @@ namespace :monit do
|
|
5
5
|
|
6
6
|
HUP's the process from the pid file, if it exists.
|
7
7
|
|
8
|
-
<dl>
|
9
|
-
<dt>monit_pid_path</dt>
|
10
|
-
<dd>Path to monit pid file</dd>
|
11
|
-
<dd class="default">Defaults to @/var/run/monit.pid@</dd>
|
12
|
-
</dl>
|
13
8
|
"Source":#{link_to_source(__FILE__)}
|
14
9
|
DESC
|
10
|
+
task_arg(:monit_pid_path, "Path to monit pid file", :default => "/var/run/monit.pid")
|
15
11
|
task :restart do
|
16
|
-
|
17
|
-
|
18
|
-
run_via %{sh -c "[ ! -e '#{monit_pid_path}' ] || kill -HUP `cat #{monit_pid_path}`"}
|
19
|
-
|
12
|
+
run_via %{sh -c "[ ! -e '#{monit_pid_path}' ] || kill -HUP `cat #{monit_pid_path}`"}
|
20
13
|
end
|
21
14
|
|
22
15
|
desc <<-DESC
|
23
16
|
Unmonitor all.
|
24
17
|
|
25
|
-
<dl>
|
26
|
-
<dt>monit_bin_path</dt>
|
27
|
-
<dd>Path to monit bin.</dd>
|
28
|
-
<dd>Defaults to @monit@</dd>
|
29
|
-
</dl>
|
30
18
|
"Source":#{link_to_source(__FILE__)}
|
31
19
|
DESC
|
20
|
+
task_arg(:monit_bin_path, "Path to monit bin.", :default => "monit")
|
32
21
|
task :unmonitor_all do
|
33
|
-
fetch_or_default(:monit_bin_path, "monit")
|
34
|
-
|
35
22
|
run_via "#{monit_bin_path} unmonitor all"
|
36
23
|
end
|
37
24
|
|
38
25
|
desc <<-DESC
|
39
26
|
Monitor all.
|
40
27
|
|
41
|
-
<dl>
|
42
|
-
<dt>monit_bin_path</dt>
|
43
|
-
<dd>Path to monit bin.</dd>
|
44
|
-
<dd>Defaults to @monit@</dd>
|
45
|
-
</dl>
|
46
28
|
"Source":#{link_to_source(__FILE__)}
|
47
29
|
DESC
|
30
|
+
task_arg(:monit_bin_path, "Path to monit bin.", :default => "monit")
|
48
31
|
task :monitor_all do
|
49
|
-
fetch_or_default(:monit_bin_path, "monit")
|
50
|
-
|
51
32
|
run_via "#{monit_bin_path} monitor all"
|
52
33
|
end
|
53
34
|
|
data/lib/recipes/monit/merb.rb
CHANGED
@@ -8,17 +8,13 @@ namespace :merb do
|
|
8
8
|
|
9
9
|
"Source":#{link_to_source(__FILE__)}
|
10
10
|
DESC
|
11
|
+
task_arg(:merb_nodes, "Number of nodes in merb cluster")
|
12
|
+
task_arg(:merb_port, "Starting port")
|
13
|
+
task_arg(:monit_conf_dir, "Monit config directory", :default => "/etc/monit")
|
14
|
+
task_arg(:merb_pid_dir, "Merb pid directory", :default => Proc.new {"#{shared_path}/pids"}, :default_desc => "\#{shared_path}/pids")
|
15
|
+
task_arg(:merb_monitrc_template, "Merb monitrc template", :default => "merb/merb.monitrc.erb")
|
11
16
|
task :setup do
|
12
17
|
|
13
|
-
# Settings
|
14
|
-
fetch(:merb_nodes)
|
15
|
-
fetch(:merb_port)
|
16
|
-
fetch_or_default(:merb_application, "merb_#{application}")
|
17
|
-
fetch_or_default(:merb_initscript_name, "merb_#{application}")
|
18
|
-
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
19
|
-
|
20
|
-
fetch_or_default(:merb_pid_dir, "#{shared_path}/pids")
|
21
|
-
|
22
18
|
processes = []
|
23
19
|
ports = (0...merb_nodes).collect { |i| merb_port + i }
|
24
20
|
ports.each do |port|
|
@@ -32,9 +28,8 @@ namespace :merb do
|
|
32
28
|
end
|
33
29
|
|
34
30
|
set :processes, processes
|
35
|
-
|
36
|
-
|
37
|
-
sudo "install -o root /tmp/#{merb_application}.monitrc #{monit_conf_dir}/#{merb_application}.monitrc"
|
31
|
+
|
32
|
+
utils.install_template(merb_monitrc_template, "#{monit_conf_dir}/#{merb_application}.monitrc")
|
38
33
|
end
|
39
34
|
|
40
35
|
desc "Restart merb (for application)"
|
data/lib/recipes/monit/mysql.rb
CHANGED
@@ -5,28 +5,12 @@ namespace :mysql do
|
|
5
5
|
desc <<-DESC
|
6
6
|
Install mysql monit hooks.
|
7
7
|
|
8
|
-
<dl>
|
9
|
-
<dt>mysql_pid_path</dt>
|
10
|
-
<dd>Path to mysql pid file</dd>
|
11
|
-
|
12
|
-
<dt>db_port</dt>
|
13
|
-
<dd>Mysql port</dd>
|
14
|
-
<dd class="default">Defaults to @3306@</dd>
|
15
|
-
|
16
|
-
<dt>monit_conf_dir</dt>
|
17
|
-
<dd>Monitrd directory.</dd>
|
18
|
-
<dd class="default">Defaults to @"/etc/monit"@</dd>
|
19
|
-
</dl>
|
20
|
-
|
21
8
|
"Source":#{link_to_source(__FILE__)}
|
22
9
|
DESC
|
10
|
+
task_arg(:mysql_pid_path, "Path to mysql pid file", :default => "/var/run/mysqld/mysqld.pid")
|
11
|
+
task_arg(:mysql_port, "Mysql port", :default => 3306)
|
12
|
+
task_arg(:monit_conf_dir, "Monitrd directory", :default => "/etc/monit")
|
23
13
|
task :install do
|
24
|
-
|
25
|
-
# Settings
|
26
|
-
fetch_or_default(:mysql_pid_path, "/var/run/mysqld/mysqld.pid")
|
27
|
-
fetch_or_default(:mysql_port, 3306)
|
28
|
-
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
29
|
-
|
30
14
|
put template.load("mysql/mysql.monitrc.erb", binding), "/tmp/mysql.monitrc"
|
31
15
|
run_via "install -o root /tmp/mysql.monitrc #{monit_conf_dir}/mysql.monitrc"
|
32
16
|
end
|
data/lib/recipes/monit/nginx.rb
CHANGED
@@ -5,25 +5,11 @@ namespace :nginx do
|
|
5
5
|
desc <<-DESC
|
6
6
|
Install nginx monit hooks.
|
7
7
|
|
8
|
-
<dl>
|
9
|
-
<dt>nginx_pid_path</dt>
|
10
|
-
<dd>Path to nginx pid file</dd>
|
11
|
-
<dd>Defaults to /var/run/nginx.pid</dd>
|
12
|
-
<dd>@set :nginx_pid_path, "/var/run/nginx.pid"@</dd>
|
13
|
-
|
14
|
-
<dt>monit_conf_dir</dt>
|
15
|
-
<dd>Destination for monitrc.</dd>
|
16
|
-
<dd>Defaults to "/etc/monit"</dd>
|
17
|
-
<dd>@set :monit_conf_dir, "/etc/monit"@</dd>
|
18
|
-
</dl>
|
19
8
|
"Source":#{link_to_source(__FILE__)}
|
20
9
|
DESC
|
10
|
+
task_arg(:nginx_pid_path, "Path to nginx pid file", :default => "/var/run/nginx.pid")
|
11
|
+
task_arg(:monit_conf_dir, "Destination for monitrc", :default => "/etc/monit")
|
21
12
|
task :install do
|
22
|
-
|
23
|
-
# Settings
|
24
|
-
fetch_or_default(:nginx_pid_path, "/var/run/nginx.pid")
|
25
|
-
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
26
|
-
|
27
13
|
put template.load("nginx/nginx.monitrc.erb", binding), "/tmp/nginx.monitrc"
|
28
14
|
run_via "install -o root /tmp/nginx.monitrc #{monit_conf_dir}/nginx.monitrc"
|
29
15
|
end
|
data/lib/recipes/monit/sphinx.rb
CHANGED
@@ -4,25 +4,34 @@ namespace :sphinx do
|
|
4
4
|
|
5
5
|
desc <<-DESC
|
6
6
|
Create monit configuration for sphinx.\n
|
7
|
-
|
8
|
-
*sphinx_pid_path*: Location for sphinx pid. _Defaults to "[shared_path]/pids/searchd.pid"_\n
|
9
|
-
|
7
|
+
|
10
8
|
"Source":#{link_to_source(__FILE__)}
|
11
9
|
DESC
|
10
|
+
task_arg(:monit_conf_dir, :default => "/etc/monit")
|
11
|
+
task_arg(:sphinx_pid_path, :default => Proc.new{"#{shared_path}/pids/searchd.pid"}, :default_desc => "\#{shared_path}/pids/searchd.pid")
|
12
12
|
task :setup do
|
13
|
-
|
14
|
-
# Settings
|
15
|
-
fetch_or_default(:monit_conf_dir, "/etc/monit")
|
16
|
-
fetch_or_default(:sphinx_pid_path, "#{shared_path}/pids/searchd.pid")
|
17
|
-
|
18
13
|
put template.load("sphinx/sphinx.monitrc.erb"), "/tmp/sphinx_#{application}.monitrc"
|
19
14
|
sudo "install -o root /tmp/sphinx_#{application}.monitrc #{monit_conf_dir}/sphinx_#{application}.monitrc"
|
20
15
|
end
|
21
16
|
|
22
|
-
desc "Restart sphinx"
|
17
|
+
desc "Restart sphinx application (through monit)"
|
23
18
|
task :restart do
|
24
|
-
|
25
|
-
|
19
|
+
fetch_or_default(:monit_bin_path, "monit")
|
20
|
+
sudo "#{monit_bin_path} restart sphinx_#{application}"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Start sphinx application (through monit)"
|
24
|
+
task :start do
|
25
|
+
fetch_or_default(:monit_bin_path, "monit")
|
26
|
+
sudo "#{monit_bin_path} start sphinx_#{application}"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Stop sphinx application (through monit)"
|
30
|
+
task :stop do
|
31
|
+
fetch_or_default(:monit_bin_path, "monit")
|
32
|
+
sudo "#{monit_bin_path} stop sphinx_#{application}"
|
33
|
+
end
|
34
|
+
|
26
35
|
|
27
36
|
end
|
28
37
|
|
data/lib/recipes/mysql.rb
CHANGED
@@ -4,45 +4,19 @@ namespace :mysql do
|
|
4
4
|
desc <<-DESC
|
5
5
|
Create database, database user, and set grant permissions.
|
6
6
|
|
7
|
-
<dl>
|
8
|
-
<dt>db_name</dt>
|
9
|
-
<dd>Database name (application).</dd>
|
10
|
-
|
11
|
-
<dt>db_user</dt>
|
12
|
-
<dd>Database user (application).</dd>
|
13
|
-
|
14
|
-
<dt>db_pass</dt>
|
15
|
-
<dd>Database password (application).</dd>
|
16
|
-
|
17
|
-
<dt>mysql_grant_locations</dt>
|
18
|
-
<dd>Grant locations. </dd>
|
19
|
-
<dd>Defaults to @[ "localhost" ]@</dd>
|
20
|
-
|
21
|
-
<dt>mysql_grant_priv_type</dt>
|
22
|
-
<dd>Grant privilege types.</dd>
|
23
|
-
<dd>Defaults to @ALL@</dd>
|
24
|
-
|
25
|
-
<dt>mysql_admin_user</dt>
|
26
|
-
<dd>Mysql admin user.</dd>
|
27
|
-
<dd>Defaults to password prompt.</dd>
|
28
|
-
|
29
|
-
<dt>mysql_admin_password</dt>
|
30
|
-
<dd>Mysql admin password.</dd>
|
31
|
-
<dd>Defaults to password prompt.</dd>
|
32
|
-
</dl>
|
33
7
|
"Source":#{link_to_source(__FILE__)}
|
34
8
|
DESC
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
fetch_or_default(:mysql_admin_password, prompt.password('Mysql admin password: '))
|
43
|
-
fetch_or_default(:mysql_grant_priv_type, "ALL")
|
44
|
-
fetch_or_default(:mysql_grant_locations, [ "localhost" ])
|
9
|
+
task_arg(:db_name, "Database name (application)")
|
10
|
+
task_arg(:db_user, "Database user (application)")
|
11
|
+
task_arg(:db_pass, "Database password (application)")
|
12
|
+
task_arg(:mysql_admin_user, "Mysql admin user", :default => "root")
|
13
|
+
task_arg(:mysql_admin_password, "Mysql admin password",
|
14
|
+
:default => Proc.new { prompt.password('Mysql admin password: ') },
|
15
|
+
:example => "prompt.password('Mysql admin password: ')")
|
45
16
|
|
17
|
+
task_arg(:mysql_grant_priv_type, "Grant privilege types", :default => "ALL")
|
18
|
+
task_arg(:mysql_grant_locations, "Grant locations", :default => ["localhost"])
|
19
|
+
task :setup do
|
46
20
|
sql = template.load("mysql/install_db.sql.erb")
|
47
21
|
|
48
22
|
logger.trace "Running sql:\n#{sql}\n"
|
@@ -55,26 +29,12 @@ namespace :mysql do
|
|
55
29
|
desc <<-DESC
|
56
30
|
Create my.cnf based on template.
|
57
31
|
|
58
|
-
<dl>
|
59
|
-
<dt>my_cnf_template</dt>
|
60
|
-
<dd>Path to my.cnf template</dd>
|
61
|
-
|
62
|
-
<dt>db_socket</dt>
|
63
|
-
<dd>Path to mysql .sock</dd>
|
64
|
-
<dd class="default">Defaults to @"/var/lib/mysql/mysql.sock"@</dd>
|
65
|
-
|
66
|
-
<dt>db_port</dt>
|
67
|
-
<dd>Mysql port</dd>
|
68
|
-
<dd class="default">Defaults to @3306@</dd>
|
69
|
-
</dl>
|
70
|
-
|
71
32
|
"Source":#{link_to_source(__FILE__)}
|
72
33
|
DESC
|
34
|
+
task_arg(:my_cnf_template, "Path to my.cnf template", :default => "mysql/my.cnf.innodb_1024.erb")
|
35
|
+
task_arg(:db_socket, "Path to mysql .sock", :default => "/var/lib/mysql/mysql.sock")
|
36
|
+
task_arg(:db_port, "Mysql port", :default => 3306)
|
73
37
|
task :install_my_cnf do
|
74
|
-
fetch_or_default(:my_cnf_template, "mysql/my.cnf.innodb_1024.erb")
|
75
|
-
fetch_or_default(:db_socket, "/var/lib/mysql/mysql.sock")
|
76
|
-
fetch_or_default(:db_port, 3306)
|
77
|
-
|
78
38
|
utils.install_template(my_cnf_template, "/etc/my.cnf")
|
79
39
|
end
|
80
40
|
|
data/lib/recipes/nginx.rb
CHANGED
@@ -6,80 +6,24 @@ namespace :nginx do
|
|
6
6
|
desc <<-DESC
|
7
7
|
Generate the nginx vhost include.
|
8
8
|
|
9
|
-
<dl>
|
10
|
-
<dt>nginx_upstream_name</dt>
|
11
|
-
<dd>Application name (for upstream definition).</dd>
|
12
|
-
<dd class="default">Defaults to @:application@</dd>
|
13
|
-
|
14
|
-
<dt>nginx_upstream_size</dt>
|
15
|
-
<dd>Number of nodes for upstream.</dd>
|
16
|
-
<dd>@set :nginx_upstream_size, 3@</dd>
|
17
|
-
|
18
|
-
<dt>nginx_upstream_port</dt>
|
19
|
-
<dd>Starting port for upstream. If there are 3 nodes with port 9000, then instances will be at 9000, 9001, and 9002</dd>
|
20
|
-
<dd>@set :nginx_upstream_port, 9000@</dd>
|
21
|
-
|
22
|
-
<dt>domain_name</dt>: Domain name for nginx virtual host, (without www prefix).</dd>
|
23
|
-
<dd>@set :domain_name, "foo.com"@</dd>
|
24
|
-
</dl>
|
25
|
-
|
26
9
|
"Source":#{link_to_source(__FILE__)}
|
27
10
|
DESC
|
11
|
+
task_arg(:nginx_upstream_name, "Application name (for upstream definition)",
|
12
|
+
:default => Proc.new { fetch(:application) },
|
13
|
+
:default_desc => "fetch(:application)")
|
14
|
+
|
15
|
+
task_arg(:nginx_upstream_size, "Number of nodes for upstream")
|
16
|
+
task_arg(:nginx_upstream_port, "Starting port for upstream. If there are 3 nodes with port 9000, then instances will be at 9000, 9001, and 9002")
|
17
|
+
task_arg(:domain_name, "Domain name")
|
18
|
+
task_arg(:nginx_vhost_template, "Path to nginx vhost template", :default => "nginx/nginx_vhost_generic.conf.erb")
|
28
19
|
task :setup do
|
29
20
|
|
30
|
-
# Settings
|
31
|
-
fetch_or_default(:nginx_upstream_name, fetch(:application))
|
32
|
-
fetch(:nginx_upstream_size)
|
33
|
-
fetch(:nginx_upstream_port)
|
34
|
-
|
35
21
|
set :nginx_upstream_ports, (0...nginx_upstream_size.to_i).collect { |i| nginx_upstream_port.to_i + i }
|
36
22
|
set :public_path, current_path + "/public"
|
37
23
|
|
38
|
-
utils.install_template(
|
24
|
+
utils.install_template(:nginx_vhost_template, "/etc/nginx/vhosts/#{nginx_upstream_name}.conf")
|
39
25
|
end
|
40
26
|
|
41
27
|
end
|
42
28
|
|
43
|
-
namespace :mongrel do
|
44
|
-
desc <<-DESC
|
45
|
-
Generate the nginx vhost include (for a mongrel setup).
|
46
|
-
|
47
|
-
*THIS IS DEPRECATED*: Use @nginx:host:setup@
|
48
|
-
|
49
|
-
<dl>
|
50
|
-
<dt>mongrel_application</dt>
|
51
|
-
<dd>Mongrel application.</dd>
|
52
|
-
<dd class="default">Defaults to @:application@</dd>
|
53
|
-
|
54
|
-
<dt>mongrel_size</dt>
|
55
|
-
<dd>Number of mongrels.</dd>
|
56
|
-
<dd>@set :mongrel_size, 3@</dd>
|
57
|
-
|
58
|
-
<dt>*mongrel_port</dt>
|
59
|
-
<dd>Starting port for mongrels. If there are 3 mongrels with port 9000, then instances will be at 9000, 9001, and 9002</dd>
|
60
|
-
<dd>@set :mongrel_port, 9000@</dd>
|
61
|
-
|
62
|
-
<dt>domain_name</dt>: Domain name for nginx virtual host, (without www prefix).</dd>
|
63
|
-
<dd>@set :domain_name, "foo.com"@</dd>
|
64
|
-
</dl>
|
65
|
-
"Source":#{link_to_source(__FILE__)}
|
66
|
-
DESC
|
67
|
-
task :setup do
|
68
|
-
|
69
|
-
# Settings
|
70
|
-
fetch(:mongrel_size)
|
71
|
-
fetch(:mongrel_port)
|
72
|
-
fetch(:domain_name)
|
73
|
-
fetch_or_default(:mongrel_application, fetch(:application))
|
74
|
-
|
75
|
-
set :ports, (0...mongrel_size).collect { |i| mongrel_port + i }
|
76
|
-
set :public_path, current_path + "/public"
|
77
|
-
|
78
|
-
run "mkdir -p #{shared_path}/config"
|
79
|
-
put template.load("nginx/nginx_vhost.conf.erb"), "/tmp/nginx_#{mongrel_application}.conf"
|
80
|
-
|
81
|
-
sudo "install -o root /tmp/nginx_#{mongrel_application}.conf /etc/nginx/vhosts/#{mongrel_application}.conf"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
29
|
end
|