rubber 1.0.2
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/CHANGELOG +39 -0
- data/COPYING +339 -0
- data/README +6 -0
- data/TODO +11 -0
- data/VERSION +1 -0
- data/bin/vulcanize +41 -0
- data/generators/vulcanize/USAGE +6 -0
- data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +5 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +62 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +30 -0
- data/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +7 -0
- data/generators/vulcanize/templates/apache/templates.yml +1 -0
- data/generators/vulcanize/templates/base/Capfile +14 -0
- data/generators/vulcanize/templates/base/config/deploy.rb +55 -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 +104 -0
- data/generators/vulcanize/templates/base/config/rubber/rubber.yml +241 -0
- data/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -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_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
- data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
- data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
- data/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/role/haproxy/haproxy-passenger.conf +19 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/rubber-complete.yml +40 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +10 -0
- data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -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-base.conf +26 -0
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -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 +7 -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/mongrel/mongrel_cluster.yml +12 -0
- data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/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 +46 -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 +156 -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 +46 -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/nginx/crontab +9 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
- data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
- data/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
- data/generators/vulcanize/templates/nginx/templates.yml +1 -0
- data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +37 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +6 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +10 -0
- data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +12 -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 +38 -0
- data/lib/rubber/capistrano.rb +1 -0
- data/lib/rubber/cloud.rb +13 -0
- data/lib/rubber/cloud/aws.rb +305 -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 +73 -0
- data/lib/rubber/dns/zerigo.rb +131 -0
- data/lib/rubber/environment.rb +161 -0
- data/lib/rubber/generator.rb +197 -0
- data/lib/rubber/instance.rb +165 -0
- data/lib/rubber/recipes/rubber.rb +89 -0
- data/lib/rubber/recipes/rubber/bundles.rb +28 -0
- data/lib/rubber/recipes/rubber/deploy.rb +90 -0
- data/lib/rubber/recipes/rubber/instances.rb +348 -0
- data/lib/rubber/recipes/rubber/load_balancers.rb +44 -0
- data/lib/rubber/recipes/rubber/security_groups.rb +189 -0
- data/lib/rubber/recipes/rubber/setup.rb +357 -0
- data/lib/rubber/recipes/rubber/static_ips.rb +107 -0
- data/lib/rubber/recipes/rubber/utils.rb +203 -0
- data/lib/rubber/recipes/rubber/volumes.rb +264 -0
- data/lib/rubber/tasks/rubber.rb +221 -0
- data/lib/rubber/util.rb +37 -0
- data/test/environment_test.rb +118 -0
- data/test/generator_test.rb +323 -0
- data/test/instance_test.rb +93 -0
- data/test/test_helper.rb +4 -0
- data/test/util_test.rb +16 -0
- metadata +274 -0
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
include /etc/nginx/rubber/*.conf;
|
|
42
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = "/etc/nginx/rubber/tools.conf"
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# This server is setup to serve http.
|
|
7
|
+
server
|
|
8
|
+
{
|
|
9
|
+
listen <%= rubber_env.web_tools_port %>;
|
|
10
|
+
server_name <%= rubber_env.full_host %>;
|
|
11
|
+
root /var/www;
|
|
12
|
+
|
|
13
|
+
rewrite (.*) https://$host:<%= rubber_env.web_tools_ssl_port %>$1 break;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
# This server is setup to serve https.
|
|
17
|
+
server
|
|
18
|
+
{
|
|
19
|
+
listen <%= rubber_env.web_tools_ssl_port %>;
|
|
20
|
+
server_name <%= rubber_env.full_host %>;
|
|
21
|
+
|
|
22
|
+
ssl on;
|
|
23
|
+
ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem;
|
|
24
|
+
ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key;
|
|
25
|
+
# ssl_certificate <%= RUBBER_ROOT %>/config/snapmylife.com.crt;
|
|
26
|
+
# ssl_certificate_key <%= RUBBER_ROOT %>/config/snapmylife.com.key;
|
|
27
|
+
|
|
28
|
+
auth_basic "Rubber Admin Tools";
|
|
29
|
+
auth_basic_user_file <%= RUBBER_ROOT %>/config/<%= rubber_env.app_name %>.auth;
|
|
30
|
+
|
|
31
|
+
client_max_body_size 10M;
|
|
32
|
+
root /var/www;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
location /
|
|
36
|
+
{
|
|
37
|
+
# If the file exists as a static file serve it directly without
|
|
38
|
+
# running all the other rewrite tests on it
|
|
39
|
+
if (-f $request_filename)
|
|
40
|
+
{
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# check for index.html for directory index
|
|
45
|
+
# if its there on the filesystem then rewite
|
|
46
|
+
# the url to add /index.html to the end of it
|
|
47
|
+
# and then break to send it to the next config rules.
|
|
48
|
+
if (-f $request_filename/index.html)
|
|
49
|
+
{
|
|
50
|
+
rewrite (.*) $1/index.html break;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
include /etc/nginx/rubber/tools/*.conf;
|
|
55
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
|
|
14
|
+
<li><a href="/munin/">Munin</a></li>
|
|
15
|
+
|
|
16
|
+
<% if cruise_host = rubber_instances.for_role('cruise').first %>
|
|
17
|
+
<li><a href="http://<%= cruise_host %>/cruise/">CruiseControl</a></li>
|
|
18
|
+
<% end %>
|
|
19
|
+
|
|
20
|
+
<% rubber_instances.for_role('haproxy').each do |ic| %>
|
|
21
|
+
<li><a href="/haproxy_<%= ic.name %>/">HAProxy <%= ic.name %></a></li>
|
|
22
|
+
<% end %>
|
|
23
|
+
|
|
24
|
+
<% rubber_instances.each do |ic| %>
|
|
25
|
+
<li><a href="/monit_<%= ic.name %>/">Monit <%= ic.name %></a></li>
|
|
26
|
+
<% end %>
|
|
27
|
+
|
|
28
|
+
</ul>
|
|
29
|
+
</body>
|
|
30
|
+
</html>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
description: The nginx module
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
namespace :rubber do
|
|
3
|
+
|
|
4
|
+
namespace :passenger do
|
|
5
|
+
|
|
6
|
+
rubber.allow_optional_tasks(self)
|
|
7
|
+
|
|
8
|
+
after "rubber:install_gems", "rubber:passenger:custom_install"
|
|
9
|
+
|
|
10
|
+
task :custom_install, :roles => :passenger do
|
|
11
|
+
rubber.sudo_script 'install_passenger', <<-ENDSCRIPT
|
|
12
|
+
if [[ -z `ls /usr/lib/ruby/gems/*/gems/passenger-#{rubber_env.passenger_version}/ext/apache2/mod_passenger.so 2> /dev/null` ]]; then
|
|
13
|
+
echo -en "\n\n\n\n" | passenger-install-apache2-module
|
|
14
|
+
fi
|
|
15
|
+
ENDSCRIPT
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after "rubber:setup_app_permissions", "rubber:passenger:setup_passenger_permissions"
|
|
19
|
+
|
|
20
|
+
task :setup_passenger_permissions, :roles => :passenger do
|
|
21
|
+
run "chown #{rubber_env.app_user}:#{rubber_env.app_user} #{current_path}/config/environment.rb"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# passenger depends on apache for start/stop/restart, just need these defined
|
|
25
|
+
# as apache hooks into standard deploy lifecycle
|
|
26
|
+
|
|
27
|
+
deploy.task :restart, :roles => :app do
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
deploy.task :stop, :roles => :app do
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
deploy.task :start, :roles => :app do
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
end
|
|
37
|
+
end
|
data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = "/etc/munin/plugins/passenger_status"
|
|
3
|
+
@perms = 0755
|
|
4
|
+
%>#!/usr/bin/env ruby
|
|
5
|
+
|
|
6
|
+
# from http://gist.github.com/21328
|
|
7
|
+
# by Dan Manges, http://www.dcmanges.com/blog/rails-application-visualization-with-munin
|
|
8
|
+
|
|
9
|
+
def output_config
|
|
10
|
+
puts <<-END
|
|
11
|
+
graph_category App
|
|
12
|
+
graph_title passenger status
|
|
13
|
+
graph_vlabel count
|
|
14
|
+
|
|
15
|
+
sessions.label sessions
|
|
16
|
+
max.label max processes
|
|
17
|
+
running.label running processes
|
|
18
|
+
active.label active processes
|
|
19
|
+
END
|
|
20
|
+
exit 0
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def output_values
|
|
24
|
+
status = `sudo /usr/bin/passenger-status`
|
|
25
|
+
unless $?.success?
|
|
26
|
+
$stderr.puts "failed executing passenger-status"
|
|
27
|
+
exit 1
|
|
28
|
+
end
|
|
29
|
+
status =~ /max\s+=\s+(\d+)/
|
|
30
|
+
puts "max.value #{$1}"
|
|
31
|
+
|
|
32
|
+
status =~ /count\s+=\s+(\d+)/
|
|
33
|
+
puts "running.value #{$1}"
|
|
34
|
+
|
|
35
|
+
status =~ /active\s+=\s+(\d+)/
|
|
36
|
+
puts "active.value #{$1}"
|
|
37
|
+
|
|
38
|
+
total_sessions = 0
|
|
39
|
+
status.scan(/Sessions: (\d+)/).flatten.each { |count| total_sessions += count.to_i }
|
|
40
|
+
puts "sessions.value #{total_sessions}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
if ARGV[0] == "config"
|
|
44
|
+
output_config
|
|
45
|
+
else
|
|
46
|
+
output_values
|
|
47
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = "/etc/apache2/sites-available/#{rubber_env.app_name}-passenger"
|
|
3
|
+
@post = "a2enmod rewrite && a2enmod ssl && a2ensite #{rubber_env.app_name}-passenger"
|
|
4
|
+
%>
|
|
5
|
+
|
|
6
|
+
<% [rubber_env.passenger_listen_port, rubber_env.passenger_listen_ssl_port].each do |port| %>
|
|
7
|
+
|
|
8
|
+
Listen <%= port %>
|
|
9
|
+
<VirtualHost *:<%= port %>>
|
|
10
|
+
ServerName <%= rubber_env.domain %>
|
|
11
|
+
<%- if rubber_env.web_aliases -%>
|
|
12
|
+
ServerAlias <%= rubber_env.web_aliases.join(" ") %>
|
|
13
|
+
<%- end -%>
|
|
14
|
+
DocumentRoot <%= RUBBER_ROOT + "/public" %>
|
|
15
|
+
|
|
16
|
+
ErrorDocument 404 /404.html
|
|
17
|
+
ErrorDocument 500 /500.html
|
|
18
|
+
|
|
19
|
+
SetEnvIf User-Agent "^(.*MSIE.*)|(.*AppleWebKit.*)$" nokeepalive
|
|
20
|
+
|
|
21
|
+
RailsEnv <%= RUBBER_ENV %>
|
|
22
|
+
RailsAllowModRewrite on
|
|
23
|
+
|
|
24
|
+
RewriteEngine On
|
|
25
|
+
RewriteCond %{HTTP_HOST} ^<%= rubber_env.domain %>$
|
|
26
|
+
RewriteRule ^(.*)$ http://www.<%= rubber_env.domain %>$1 [R,L]
|
|
27
|
+
|
|
28
|
+
# Include <%= RUBBER_ROOT %>/config/apache/rewrites.conf
|
|
29
|
+
|
|
30
|
+
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
|
|
31
|
+
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
|
|
32
|
+
RewriteRule ^.*$ /system/maintenance.html [L]
|
|
33
|
+
|
|
34
|
+
<% if port == rubber_env.passenger_listen_ssl_port %>
|
|
35
|
+
SSLEngine on
|
|
36
|
+
SSLOptions +FakeBasicAuth +ExportCertData +StrictRequire
|
|
37
|
+
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
|
|
38
|
+
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
|
|
39
|
+
# SSLCertificateFile <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.crt
|
|
40
|
+
# SSLCertificateKeyFile <%= RUBBER_ROOT %>/config/<%= rubber_env.domain %>.key
|
|
41
|
+
# SSLCertificateChainFile /etc/ssl/certs/gd_intermediate_bundle.crt
|
|
42
|
+
<% end %>
|
|
43
|
+
|
|
44
|
+
</VirtualHost>
|
|
45
|
+
|
|
46
|
+
<% end %>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = '/etc/apache2/mods-available/passenger.conf'
|
|
3
|
+
@post = 'cd /etc/apache2/mods-enabled && ln -fs ../mods-available/passenger.conf'
|
|
4
|
+
%>
|
|
5
|
+
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-<%= rubber_env.passenger_version %>/ext/apache2/mod_passenger.so
|
|
6
|
+
PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-<%= rubber_env.passenger_version %>
|
|
7
|
+
PassengerRuby /usr/bin/ruby
|
|
8
|
+
PassengerUseGlobalQueue on
|
|
9
|
+
|
|
10
|
+
PassengerMaxPoolSize <%= rubber_env.max_app_connections %>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
passenger_version: 2.2.5
|
|
2
|
+
passenger_listen_port: 7000
|
|
3
|
+
passenger_listen_ssl_port: 7001
|
|
4
|
+
max_app_connections: 20
|
|
5
|
+
|
|
6
|
+
role_dependencies:
|
|
7
|
+
passenger: [apache]
|
|
8
|
+
|
|
9
|
+
roles:
|
|
10
|
+
app:
|
|
11
|
+
packages: [apache2-mpm-prefork, apache2-prefork-dev]
|
|
12
|
+
gems: [fastthread, rack, [passenger, "#{passenger_version}"]]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
description: Phusion Passenger module (Apache2)
|
|
@@ -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 -qN 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
|