sml-rubber 0.9.1
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +339 -0
- data/README +6 -0
- data/TODO +9 -0
- data/VERSION +1 -0
- data/generators/vulcanize/USAGE +6 -0
- data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +45 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web/deflate.conf +10 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web/expires.conf +9 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web/headers.conf +6 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web/setenvif.conf +52 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web/vhost.conf +27 -0
- data/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +15 -0
- data/generators/vulcanize/templates/apache/templates.yml +1 -0
- data/generators/vulcanize/templates/base/Capfile +17 -0
- data/generators/vulcanize/templates/base/config/deploy.rb +77 -0
- data/generators/vulcanize/templates/base/config/rubber/common/crontab +16 -0
- data/generators/vulcanize/templates/base/config/rubber/common/profile.rc +9 -0
- data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +56 -0
- data/generators/vulcanize/templates/base/config/rubber/rubber.yml +221 -0
- data/generators/vulcanize/templates/base/lib/tasks/rubber.rake +18 -0
- data/generators/vulcanize/templates/base/script/cron-rake +18 -0
- data/generators/vulcanize/templates/base/script/cron-runner +18 -0
- data/generators/vulcanize/templates/base/script/cron-sh +67 -0
- data/generators/vulcanize/templates/base/templates.yml +1 -0
- data/generators/vulcanize/templates/complete_mysql/templates.yml +6 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +8 -0
- data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +74 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
- data/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
- data/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
- data/generators/vulcanize/templates/cruise/templates.yml +1 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy.conf +44 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +6 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +17 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +12 -0
- data/generators/vulcanize/templates/haproxy/templates.yml +1 -0
- data/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
- data/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
- data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
- data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
- data/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
- data/generators/vulcanize/templates/memcached/templates.yml +1 -0
- data/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
- data/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/role/app/mongrel_cluster.yml +12 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/role/app/monit-mongrel.conf +20 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
- data/generators/vulcanize/templates/mongrel/templates.yml +1 -0
- data/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
- data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +251 -0
- data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +32 -0
- data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
- data/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
- data/generators/vulcanize/templates/monit/templates.yml +1 -0
- data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
- data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
- data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +30 -0
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +80 -0
- data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
- data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +57 -0
- data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
- data/generators/vulcanize/templates/munin/templates.yml +1 -0
- data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +11 -0
- data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +178 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +167 -0
- data/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
- data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +38 -0
- data/generators/vulcanize/templates/mysql/templates.yml +1 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +173 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
- data/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
- data/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
- data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web/crontab +9 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web/monit-nginx.conf +9 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web/nginx.conf +133 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/index.html +23 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +74 -0
- data/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +33 -0
- data/generators/vulcanize/templates/nginx/templates.yml +1 -0
- data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +27 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/web/passenger.conf +8 -0
- data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +4 -0
- data/generators/vulcanize/templates/passenger/templates.yml +1 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +10 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
- data/generators/vulcanize/templates/sphinx/templates.yml +1 -0
- data/generators/vulcanize/vulcanize_generator.rb +67 -0
- data/lib/capistrano/hostcmd.rb +12 -0
- data/lib/rubber.rb +37 -0
- data/lib/rubber/capistrano.rb +1 -0
- data/lib/rubber/cloud.rb +13 -0
- data/lib/rubber/cloud/aws.rb +261 -0
- data/lib/rubber/cloud/base.rb +16 -0
- data/lib/rubber/configuration.rb +47 -0
- data/lib/rubber/dns.rb +13 -0
- data/lib/rubber/dns/base.rb +69 -0
- data/lib/rubber/dns/dyndns.rb +63 -0
- data/lib/rubber/dns/nettica.rb +56 -0
- data/lib/rubber/dns/zerigo.rb +121 -0
- data/lib/rubber/environment.rb +161 -0
- data/lib/rubber/generator.rb +197 -0
- data/lib/rubber/instance.rb +113 -0
- data/lib/rubber/recipes/rubber.rb +88 -0
- data/lib/rubber/recipes/rubber/bundles.rb +28 -0
- data/lib/rubber/recipes/rubber/deploy.rb +66 -0
- data/lib/rubber/recipes/rubber/instances.rb +298 -0
- data/lib/rubber/recipes/rubber/security_groups.rb +149 -0
- data/lib/rubber/recipes/rubber/setup.rb +285 -0
- data/lib/rubber/recipes/rubber/static_ips.rb +107 -0
- data/lib/rubber/recipes/rubber/utils.rb +195 -0
- data/lib/rubber/recipes/rubber/volumes.rb +263 -0
- data/lib/rubber/tasks/rubber.rb +218 -0
- data/lib/rubber/util.rb +33 -0
- data/test/environment_test.rb +118 -0
- data/test/generator_test.rb +323 -0
- data/test/instance_test.rb +38 -0
- data/test/test_helper.rb +4 -0
- data/test/util_test.rb +16 -0
- metadata +246 -0
@@ -0,0 +1,9 @@
|
|
1
|
+
<%
|
2
|
+
@path = '/etc/monit/monit.d/monit-nginx.conf'
|
3
|
+
%>
|
4
|
+
<% PIDFILE = "/var/run/nginx.pid" %>
|
5
|
+
check process nginx with pidfile <%= PIDFILE %>
|
6
|
+
group nginx-<%= RUBBER_ENV %>
|
7
|
+
start program = "/etc/init.d/nginx start"
|
8
|
+
stop program = "/etc/init.d/nginx stop"
|
9
|
+
if failed host <%= rubber_env.host %> port 80 protocol http and request "/robots.txt" with timeout 10 seconds for 10 cycles then restart
|
@@ -0,0 +1,133 @@
|
|
1
|
+
<%
|
2
|
+
@path = "/etc/nginx/nginx.conf"
|
3
|
+
@post = "mkdir -p /mnt/nginx/logs"
|
4
|
+
%>
|
5
|
+
|
6
|
+
user www-data;
|
7
|
+
worker_processes 10;
|
8
|
+
|
9
|
+
pid /var/run/nginx.pid;
|
10
|
+
|
11
|
+
events
|
12
|
+
{
|
13
|
+
worker_connections 1024;
|
14
|
+
}
|
15
|
+
|
16
|
+
http
|
17
|
+
{
|
18
|
+
include /etc/nginx/mime.types;
|
19
|
+
default_type application/octet-stream;
|
20
|
+
|
21
|
+
sendfile on;
|
22
|
+
tcp_nopush on;
|
23
|
+
tcp_nodelay off;
|
24
|
+
|
25
|
+
gzip on;
|
26
|
+
gzip_http_version 1.0;
|
27
|
+
gzip_comp_level 2;
|
28
|
+
gzip_proxied any;
|
29
|
+
gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
|
30
|
+
|
31
|
+
# configure log format like to Apache's "combined" log format
|
32
|
+
log_format main
|
33
|
+
'$remote_addr - $remote_user [$time_local] '
|
34
|
+
'"$request" $status $body_bytes_sent "$http_referer" '
|
35
|
+
'"$http_user_agent" "$http_cookie"';
|
36
|
+
|
37
|
+
# default log files
|
38
|
+
error_log /mnt/nginx/logs/error.log notice;
|
39
|
+
access_log /mnt/nginx/logs/access.log main;
|
40
|
+
|
41
|
+
|
42
|
+
upstream mongrel
|
43
|
+
{
|
44
|
+
<% proxy_hosts = rubber_instances.for_role('haproxy').each do |ic| %>
|
45
|
+
server <%= ic.name %>:<%= rubber_env.haproxy_listen_port %>;
|
46
|
+
<% end %>
|
47
|
+
}
|
48
|
+
|
49
|
+
# This server is setup to serve www.
|
50
|
+
server
|
51
|
+
{
|
52
|
+
listen 80;
|
53
|
+
client_max_body_size 10M;
|
54
|
+
|
55
|
+
server_name <%= rubber_env.domain %>;
|
56
|
+
|
57
|
+
if ( $host = www.<%= rubber_env.domain %>)
|
58
|
+
{
|
59
|
+
rewrite ^\/(.*)$ http://<%= rubber_env.domain %>/$1 permanent;
|
60
|
+
}
|
61
|
+
|
62
|
+
root <%= RUBBER_ROOT + "/public" %>;
|
63
|
+
|
64
|
+
# this rewrites all the requests to the maintenance.html
|
65
|
+
# page if it exists in the doc root. This is for capistrano's
|
66
|
+
# disable web task
|
67
|
+
if (-f $document_root/system/maintenance.html)
|
68
|
+
{
|
69
|
+
rewrite ^(.*)$ /system/maintenance.html last;
|
70
|
+
break;
|
71
|
+
}
|
72
|
+
|
73
|
+
location /
|
74
|
+
{
|
75
|
+
# needed to forward user's IP address to rails
|
76
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
77
|
+
|
78
|
+
# needed for HTTPS
|
79
|
+
proxy_set_header Host $http_host;
|
80
|
+
proxy_redirect false;
|
81
|
+
proxy_max_temp_file_size 0;
|
82
|
+
|
83
|
+
|
84
|
+
# If the file exists as a static file serve it directly without
|
85
|
+
# running all the other rewrite tests on it
|
86
|
+
if (-f $request_filename)
|
87
|
+
{
|
88
|
+
break;
|
89
|
+
}
|
90
|
+
|
91
|
+
# check for index.html for directory index
|
92
|
+
# if its there on the filesystem then rewite
|
93
|
+
# the url to add /index.html to the end of it
|
94
|
+
# and then break to send it to the next config rules.
|
95
|
+
if (-f $request_filename/index.html)
|
96
|
+
{
|
97
|
+
rewrite (.*) $1/index.html break;
|
98
|
+
}
|
99
|
+
|
100
|
+
# this is the meat of the rails page caching config
|
101
|
+
# it adds .html to the end of the url and then checks
|
102
|
+
# the filesystem for that file. If it exists, then we
|
103
|
+
# rewite the url to have explicit .html on the end
|
104
|
+
# and then send it on its way to the next config rule.
|
105
|
+
# if there is no file on the fs then it sets all the
|
106
|
+
# necessary headers and proxies to our upstream mongrels
|
107
|
+
if (-f $request_filename.html)
|
108
|
+
{
|
109
|
+
rewrite (.*) $1.html break;
|
110
|
+
}
|
111
|
+
|
112
|
+
if (!-f $request_filename)
|
113
|
+
{
|
114
|
+
proxy_pass http://mongrel;
|
115
|
+
break;
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
# catch errors from proxy so we can display our error page
|
120
|
+
proxy_intercept_errors on;
|
121
|
+
|
122
|
+
error_page 500 502 503 504 /500.html;
|
123
|
+
location = /500.html
|
124
|
+
{
|
125
|
+
root <%= RUBBER_ROOT + "/public" %>;
|
126
|
+
}
|
127
|
+
error_page 404 /404.html;
|
128
|
+
location = /404.html
|
129
|
+
{
|
130
|
+
root <%= RUBBER_ROOT + "/public" %>;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
}
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%
|
2
|
+
@path = "/var/www/index.html"
|
3
|
+
%>
|
4
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
5
|
+
<html>
|
6
|
+
<head>
|
7
|
+
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
8
|
+
<title>Rubber Admin Tools</title>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<h1>Rubber Admin Tools</h1>
|
12
|
+
<ul>
|
13
|
+
<li><a href="/munin/">Munin</a></li>
|
14
|
+
<li><a href="/cruise/">CruiseControl</a></li>
|
15
|
+
<% rubber_instances.for_role('haproxy').each do |ic| %>
|
16
|
+
<li><a href="/haproxy_<%= ic.name %>/">HAProxy <%= ic.name %></a></li>
|
17
|
+
<% end %>
|
18
|
+
<% rubber_instances.each do |ic| %>
|
19
|
+
<li><a href="/monit_<%= ic.name %>/">Monit <%= ic.name %></a></li>
|
20
|
+
<% end %>
|
21
|
+
</ul>
|
22
|
+
</body>
|
23
|
+
</html>
|
@@ -0,0 +1,74 @@
|
|
1
|
+
<%
|
2
|
+
@path = "/etc/nginx/nginx.conf"
|
3
|
+
|
4
|
+
also_web = rubber_instances[rubber_env.host].role_names.include?('web') rescue false
|
5
|
+
# Only want to be additive if we are running web server on same host as tools
|
6
|
+
if also_web
|
7
|
+
@additive = ["# rubber-web_tools-start", "# rubber-web_tools-end"]
|
8
|
+
end
|
9
|
+
%>
|
10
|
+
|
11
|
+
<%# only need this section if running without nginx configured for site %>
|
12
|
+
<% if ! also_web %>
|
13
|
+
|
14
|
+
user www-data;
|
15
|
+
worker_processes 1;
|
16
|
+
|
17
|
+
error_log /var/log/nginx/error.log;
|
18
|
+
pid /var/run/nginx.pid;
|
19
|
+
|
20
|
+
events
|
21
|
+
{
|
22
|
+
worker_connections 1024;
|
23
|
+
}
|
24
|
+
|
25
|
+
<% end %>
|
26
|
+
|
27
|
+
http
|
28
|
+
{
|
29
|
+
include /etc/nginx/mime.types;
|
30
|
+
default_type application/octet-stream;
|
31
|
+
|
32
|
+
access_log /var/log/nginx/access.log;
|
33
|
+
|
34
|
+
sendfile on;
|
35
|
+
|
36
|
+
keepalive_timeout 65;
|
37
|
+
tcp_nodelay on;
|
38
|
+
|
39
|
+
gzip on;
|
40
|
+
|
41
|
+
# This server is setup to serve www.
|
42
|
+
server
|
43
|
+
{
|
44
|
+
listen <%= rubber_env.web_tools_port %>;
|
45
|
+
client_max_body_size 10M;
|
46
|
+
|
47
|
+
server_name <%= rubber_env.full_host %>;
|
48
|
+
|
49
|
+
root /var/www;
|
50
|
+
|
51
|
+
|
52
|
+
location /
|
53
|
+
{
|
54
|
+
# If the file exists as a static file serve it directly without
|
55
|
+
# running all the other rewrite tests on it
|
56
|
+
if (-f $request_filename)
|
57
|
+
{
|
58
|
+
break;
|
59
|
+
}
|
60
|
+
|
61
|
+
# check for index.html for directory index
|
62
|
+
# if its there on the filesystem then rewite
|
63
|
+
# the url to add /index.html to the end of it
|
64
|
+
# and then break to send it to the next config rules.
|
65
|
+
if (-f $request_filename/index.html)
|
66
|
+
{
|
67
|
+
rewrite (.*) $1/index.html break;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
include /etc/nginx/rubber/*.conf;
|
72
|
+
}
|
73
|
+
|
74
|
+
}
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
# Uses from base rubber config
|
3
|
+
# domain: foo.com
|
4
|
+
|
5
|
+
# Uses from appserver (mongrel) rubber config
|
6
|
+
# appserver_base_port: 8000
|
7
|
+
# appserver_count: 8
|
8
|
+
|
9
|
+
web_tools_port: 8080
|
10
|
+
|
11
|
+
security_groups:
|
12
|
+
web:
|
13
|
+
description: To open up port 80 for http server on web role
|
14
|
+
rules:
|
15
|
+
- protocol: tcp
|
16
|
+
from_port: 80
|
17
|
+
to_port: 80
|
18
|
+
source_ips: [0.0.0.0/0]
|
19
|
+
web_tools:
|
20
|
+
description: "To open up port #{web_tools_port} for internal/tools http server"
|
21
|
+
rules:
|
22
|
+
- protocol: tcp
|
23
|
+
from_port: "#{web_tools_port}"
|
24
|
+
to_port: "#{web_tools_port}"
|
25
|
+
source_ips: [0.0.0.0/0]
|
26
|
+
|
27
|
+
roles:
|
28
|
+
web:
|
29
|
+
packages: [nginx]
|
30
|
+
assigned_security_groups: [web]
|
31
|
+
web_tools:
|
32
|
+
packages: [nginx]
|
33
|
+
assigned_security_groups: [web_tools]
|
@@ -0,0 +1 @@
|
|
1
|
+
description: The nginx module
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
namespace :rubber do
|
3
|
+
|
4
|
+
namespace :passenger do
|
5
|
+
|
6
|
+
rubber.allow_optional_tasks(self)
|
7
|
+
|
8
|
+
after "rubber:base:install_rubygems", "rubber:passenger:custom_install"
|
9
|
+
|
10
|
+
task :custom_install, :roles => :web do
|
11
|
+
rubber.sudo_script 'install_passenger', <<-ENDSCRIPT
|
12
|
+
TMPDIR=`mktemp -d` || exit 1
|
13
|
+
cd $TMPDIR
|
14
|
+
# download and install current HEAD of passenger
|
15
|
+
wget -q --output-document=passenger.tgz http://github.com/FooBarWidget/passenger/tarball/master
|
16
|
+
tar -xvf passenger.tgz --strip-components 1
|
17
|
+
rake package:gem && gem install pkg/*gem --no-rdoc --no-ri
|
18
|
+
echo -en "\n\n\n\n" | passenger-install-apache2-module
|
19
|
+
wget -q http://rubyforge.org/frs/download.php/41041/ruby-enterprise_1.8.6-20080810-i386.deb
|
20
|
+
dpkg -i ruby-enterprise_1.8.6-20080810-i386.deb
|
21
|
+
# enable needed apache modules / disable ubuntu default site
|
22
|
+
a2enmod rewrite
|
23
|
+
a2dissite default
|
24
|
+
ENDSCRIPT
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%
|
2
|
+
@path = '/etc/apache2/mods-available/passenger.conf'
|
3
|
+
@post = 'cd /etc/apache2/mods-enabled && ln -fs ../mods-available/passenger.conf && /etc/init.d/apache2 restart'
|
4
|
+
%>
|
5
|
+
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.1.0/ext/apache2/mod_passenger.so
|
6
|
+
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.1.0
|
7
|
+
PassengerRuby /opt/ruby-enterprise/bin/ruby
|
8
|
+
PassengerUseGlobalQueue on
|
@@ -0,0 +1 @@
|
|
1
|
+
description: Phusion Passenger module
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<%
|
2
|
+
@path = "#{RUBBER_ROOT}/config/sphinx.yml"
|
3
|
+
%>
|
4
|
+
|
5
|
+
# Taken from: http://ts.freelancing-gods.com/rdoc/classes/ThinkingSphinx/Configuration.html
|
6
|
+
#
|
7
|
+
# Here are the default settings, relative to RUBBER_ROOT where relevant:
|
8
|
+
#
|
9
|
+
# config file:: config/#{environment}.sphinx.conf
|
10
|
+
# searchd log file:: log/searchd.log
|
11
|
+
# query log file:: log/searchd.query.log
|
12
|
+
# pid file:: log/searchd.#{environment}.pid
|
13
|
+
# searchd files:: db/sphinx/#{environment}/
|
14
|
+
# address:: 127.0.0.1
|
15
|
+
# port:: 3312
|
16
|
+
# allow star:: false
|
17
|
+
# min prefix length:: 1
|
18
|
+
# min infix length:: 1
|
19
|
+
# mem limit:: 64M
|
20
|
+
# max matches:: 1000
|
21
|
+
# morphology:: stem_en
|
22
|
+
# charset type:: utf-8
|
23
|
+
# charset table:: nil
|
24
|
+
# ignore chars:: nil
|
25
|
+
# html strip:: false
|
26
|
+
# html remove elements:: ''
|
27
|
+
#
|
28
|
+
# If you want to change these settings, create a YAML file at
|
29
|
+
# config/sphinx.yml with settings for each environment, in a similar
|
30
|
+
# fashion to database.yml - using the following keys: config_file,
|
31
|
+
# searchd_log_file, query_log_file, pid_file, searchd_file_path, port,
|
32
|
+
# allow_star, enable_star, min_prefix_len, min_infix_len, mem_limit,
|
33
|
+
# max_matches, # morphology, charset_type, charset_table, ignore_chars,
|
34
|
+
# html_strip, # html_remove_elements. I think you've got the idea.
|
35
|
+
#
|
36
|
+
# Each setting in the YAML file is optional - so only put in the ones you
|
37
|
+
# want to change.
|
38
|
+
|
39
|
+
<%= RUBBER_ENV %>:
|
40
|
+
address: <%= rubber_instances.for_role('sphinx').first.full_name rescue 'localhost' %>
|
41
|
+
mem_limit: <%= RUBBER_ENV == 'production' ? '1024M' : '64M' %>
|
42
|
+
config_file: sphinx/config/<%= RUBBER_ENV %>.sphinx.conf
|
43
|
+
searchd_file_path: sphinx/db/<%= RUBBER_ENV %>/
|
44
|
+
pid_file: <%= RUBBER_ROOT %>/log/searchd.<%= RUBBER_ENV %>.pid
|
45
|
+
searchd_log_file: <%= RUBBER_ROOT %>/log/searchd.log
|
46
|
+
query_log_file: <%= RUBBER_ROOT %>/log/searchd.query.log
|
@@ -0,0 +1,112 @@
|
|
1
|
+
# installs, starts and stops sphinx
|
2
|
+
#
|
3
|
+
# Please note that all tasks are executed as runner. So sphinx will run under
|
4
|
+
# the same userid as mongrel. This is important to allow delta indexes (mongrel
|
5
|
+
# has to send a sighup to searchd).
|
6
|
+
#
|
7
|
+
# * installation is ubuntu specific
|
8
|
+
# * start and stop tasks are using the thinking sphinx plugin
|
9
|
+
|
10
|
+
namespace :rubber do
|
11
|
+
|
12
|
+
namespace :sphinx do
|
13
|
+
|
14
|
+
rubber.allow_optional_tasks(self)
|
15
|
+
|
16
|
+
after "rubber:install_packages", "rubber:sphinx:custom_install"
|
17
|
+
|
18
|
+
task :custom_install, :roles => :sphinx do
|
19
|
+
# install sphinx from source
|
20
|
+
ver = "0.9.8.1"
|
21
|
+
rubber.run_script 'install_sphinx', <<-ENDSCRIPT
|
22
|
+
# check if already installed
|
23
|
+
if [ -x /usr/local/bin/searchd ]
|
24
|
+
then echo 'Found sphinx searchd on system'
|
25
|
+
if /usr/local/bin/searchd --help | grep 'Sphinx #{ver}'
|
26
|
+
then echo 'Sphinx version matches, no further steps needed'
|
27
|
+
exit 0
|
28
|
+
fi
|
29
|
+
fi
|
30
|
+
|
31
|
+
echo 'Installing / Upgrading sphinx #{ver}'
|
32
|
+
TMPDIR=`mktemp -d` || exit 1
|
33
|
+
cd $TMPDIR
|
34
|
+
echo 'Downloading'
|
35
|
+
wget -q http://www.sphinxsearch.com/downloads/sphinx-#{ver}.tar.gz
|
36
|
+
echo 'Unpacking'
|
37
|
+
tar xf sphinx-#{ver}.tar.gz
|
38
|
+
cd sphinx-#{ver}
|
39
|
+
./configure
|
40
|
+
make
|
41
|
+
make install
|
42
|
+
cd ; rm -rf $TMPDIR
|
43
|
+
ENDSCRIPT
|
44
|
+
end
|
45
|
+
|
46
|
+
set :sphinx_root, Proc.new {"#{shared_path}/sphinx"}
|
47
|
+
after "deploy:setup", "rubber:sphinx:setup"
|
48
|
+
after "deploy:symlink", "rubber:sphinx:config_dir"
|
49
|
+
|
50
|
+
before "deploy:stop", "rubber:sphinx:stop"
|
51
|
+
after "deploy:start", "rubber:sphinx:start"
|
52
|
+
after "deploy:restart", "rubber:sphinx:restart"
|
53
|
+
before "deploy:cold" do
|
54
|
+
before "rubber:sphinx:start", "rubber:sphinx:index"
|
55
|
+
end
|
56
|
+
before "rubber:create_staging" do
|
57
|
+
before "rubber:sphinx:start", "rubber:sphinx:index"
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Do sphinx setup tasks"
|
61
|
+
task :setup, :roles => :sphinx do
|
62
|
+
# Setup links to sphinx config/index as they need to persist between deploys
|
63
|
+
run "mkdir -p #{sphinx_root} #{sphinx_root}/config #{sphinx_root}/db"
|
64
|
+
run "chown -R #{runner}:#{runner} #{sphinx_root}"
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Setup paths for sphinx runtime"
|
68
|
+
task :config_dir, :roles => :sphinx do
|
69
|
+
run "rm -rf #{current_path}/sphinx && ln -sf #{sphinx_root} #{current_path}/sphinx"
|
70
|
+
end
|
71
|
+
|
72
|
+
# runs the given ultrasphinx rake tasks
|
73
|
+
def run_sphinx task
|
74
|
+
cmd = "cd #{current_path} && sudo -u #{runner} RAILS_ENV=#{RUBBER_ENV} rake #{task}"
|
75
|
+
run cmd
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
desc "Stops sphinx searchd"
|
80
|
+
task :stop, :roles => :sphinx, :on_error => :continue do
|
81
|
+
run_sphinx 'ts:stop'
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "Starts sphinx searchd"
|
85
|
+
task :start, :roles => :sphinx do
|
86
|
+
# rake tasks that load rails env can be slow, so
|
87
|
+
# do multiple here as a performance tweak
|
88
|
+
# config always needs to be run before start as
|
89
|
+
# rubber generates a sphinx config file with new paths
|
90
|
+
run_sphinx 'ts:config ts:start'
|
91
|
+
end
|
92
|
+
|
93
|
+
desc "Restarts sphinx searchd"
|
94
|
+
task :restart, :roles => :sphinx do
|
95
|
+
# rake tasks that load rails env can be slow, so
|
96
|
+
# do multiple here as a performance tweak
|
97
|
+
run_sphinx 'ts:config ts:stop ts:start'
|
98
|
+
end
|
99
|
+
|
100
|
+
desc "Configures sphinx index"
|
101
|
+
task :config, :roles => :sphinx do
|
102
|
+
run_sphinx 'ts:config'
|
103
|
+
end
|
104
|
+
|
105
|
+
desc "Builds sphinx index"
|
106
|
+
task :index, :roles => :sphinx do
|
107
|
+
run_sphinx 'ts:index'
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
end
|