calas-capitate 0.3.6

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.
Files changed (122) hide show
  1. data/Capfile +13 -0
  2. data/History.txt +167 -0
  3. data/License.txt +20 -0
  4. data/Manifest.txt +121 -0
  5. data/README.txt +8 -0
  6. data/Rakefile +4 -0
  7. data/config/hoe.rb +72 -0
  8. data/config/requirements.rb +17 -0
  9. data/lib/capitate.rb +56 -0
  10. data/lib/capitate/cap_ext/connections.rb +105 -0
  11. data/lib/capitate/cap_ext/docs.rb +26 -0
  12. data/lib/capitate/cap_ext/namespace.rb +34 -0
  13. data/lib/capitate/cap_ext/run_via.rb +16 -0
  14. data/lib/capitate/cap_ext/task_definition.rb +22 -0
  15. data/lib/capitate/cap_ext/variables.rb +132 -0
  16. data/lib/capitate/plugins/base.rb +140 -0
  17. data/lib/capitate/plugins/build.rb +71 -0
  18. data/lib/capitate/plugins/gem.rb +24 -0
  19. data/lib/capitate/plugins/prompt.rb +109 -0
  20. data/lib/capitate/plugins/rake.rb +25 -0
  21. data/lib/capitate/plugins/script.rb +96 -0
  22. data/lib/capitate/plugins/templates.rb +113 -0
  23. data/lib/capitate/plugins/utils.rb +151 -0
  24. data/lib/capitate/plugins/yum.rb +76 -0
  25. data/lib/capitate/recipes.rb +5 -0
  26. data/lib/capitate/task_node.rb +262 -0
  27. data/lib/capitate/version.rb +9 -0
  28. data/lib/deployment/centos-5.1-64-web/install.rb +196 -0
  29. data/lib/recipes/active_record.rb +36 -0
  30. data/lib/recipes/apache.rb +47 -0
  31. data/lib/recipes/backgroundrb.rb +29 -0
  32. data/lib/recipes/centos/backgroundjob.rb +27 -0
  33. data/lib/recipes/centos/backgroundrb.rb +23 -0
  34. data/lib/recipes/centos/centos.rb +45 -0
  35. data/lib/recipes/centos/imagemagick.rb +29 -0
  36. data/lib/recipes/centos/memcached.rb +45 -0
  37. data/lib/recipes/centos/merb.rb +23 -0
  38. data/lib/recipes/centos/mongrel_cluster.rb +54 -0
  39. data/lib/recipes/centos/monit.rb +62 -0
  40. data/lib/recipes/centos/mysql.rb +25 -0
  41. data/lib/recipes/centos/nginx.rb +64 -0
  42. data/lib/recipes/centos/ruby.rb +40 -0
  43. data/lib/recipes/centos/sphinx.rb +59 -0
  44. data/lib/recipes/docs.rb +24 -0
  45. data/lib/recipes/logrotate/backgroundjob.rb +26 -0
  46. data/lib/recipes/logrotate/backgroundrb.rb +26 -0
  47. data/lib/recipes/logrotate/merb.rb +25 -0
  48. data/lib/recipes/logrotate/mongrel_cluster.rb +29 -0
  49. data/lib/recipes/logrotate/monit.rb +28 -0
  50. data/lib/recipes/logrotate/mysql.rb +26 -0
  51. data/lib/recipes/logrotate/nginx.rb +37 -0
  52. data/lib/recipes/logrotate/rails.rb +21 -0
  53. data/lib/recipes/logrotate/sphinx.rb +21 -0
  54. data/lib/recipes/logrotated.rb +61 -0
  55. data/lib/recipes/memcached.rb +26 -0
  56. data/lib/recipes/merb.rb +32 -0
  57. data/lib/recipes/monit.rb +35 -0
  58. data/lib/recipes/monit/backgroundjob.rb +38 -0
  59. data/lib/recipes/monit/backgroundrb.rb +38 -0
  60. data/lib/recipes/monit/database.rb +25 -0
  61. data/lib/recipes/monit/memcached.rb +22 -0
  62. data/lib/recipes/monit/merb.rb +58 -0
  63. data/lib/recipes/monit/mongrel_cluster.rb +85 -0
  64. data/lib/recipes/monit/mysql.rb +20 -0
  65. data/lib/recipes/monit/nginx.rb +37 -0
  66. data/lib/recipes/monit/sphinx.rb +38 -0
  67. data/lib/recipes/monit/sshd.rb +27 -0
  68. data/lib/recipes/mysql.rb +42 -0
  69. data/lib/recipes/nginx.rb +29 -0
  70. data/lib/recipes/rails.rb +71 -0
  71. data/lib/recipes/redmine.rb +38 -0
  72. data/lib/recipes/sphinx.rb +60 -0
  73. data/lib/recipes/sshd.rb +47 -0
  74. data/lib/recipes/syslogd.rb +21 -0
  75. data/lib/templates/apache/vhost.mongrel_cluster.conf.erb +46 -0
  76. data/lib/templates/backgroundjob/backgroundjob.initd.centos.erb +54 -0
  77. data/lib/templates/backgroundjob/backgroundjob.monitrc.erb +3 -0
  78. data/lib/templates/backgroundrb/backgroundrb.initd.centos.erb +58 -0
  79. data/lib/templates/backgroundrb/backgroundrb.monitrc.erb +3 -0
  80. data/lib/templates/backgroundrb/backgroundrb.yml.erb +14 -0
  81. data/lib/templates/capistrano/Capfile +22 -0
  82. data/lib/templates/logrotated/conf.erb +3 -0
  83. data/lib/templates/memcached/memcached.initd.centos.erb +58 -0
  84. data/lib/templates/memcached/memcached.monitrc.erb +4 -0
  85. data/lib/templates/memcached/memcached.yml.erb +14 -0
  86. data/lib/templates/merb/merb-no-http.monitrc.erb +13 -0
  87. data/lib/templates/merb/merb.initd.centos.erb +123 -0
  88. data/lib/templates/merb/merb.monitrc.erb +15 -0
  89. data/lib/templates/mongrel/mongrel_cluster.initd.centos.erb +94 -0
  90. data/lib/templates/mongrel/mongrel_cluster.monitrc.erb +15 -0
  91. data/lib/templates/mongrel/mongrel_cluster.yml.erb +11 -0
  92. data/lib/templates/monit/monit.cnf +34 -0
  93. data/lib/templates/monit/monit.initd.centos.erb +68 -0
  94. data/lib/templates/monit/monitrc.erb +18 -0
  95. data/lib/templates/mysql/install_db.sql.erb +6 -0
  96. data/lib/templates/mysql/my.cnf.innodb_1024.erb +122 -0
  97. data/lib/templates/mysql/my.cnf.innodb_512.erb +127 -0
  98. data/lib/templates/mysql/mysql.monitrc.erb +6 -0
  99. data/lib/templates/nginx/nginx.conf.erb +97 -0
  100. data/lib/templates/nginx/nginx.initd.centos.erb +69 -0
  101. data/lib/templates/nginx/nginx.monitrc.erb +4 -0
  102. data/lib/templates/nginx/nginx_vhost.conf.erb +101 -0
  103. data/lib/templates/nginx/nginx_vhost_generic.conf.erb +99 -0
  104. data/lib/templates/rails/database.yml.erb +7 -0
  105. data/lib/templates/redmine/email.yml.erb +10 -0
  106. data/lib/templates/ruby/fix_openssl.sh +12 -0
  107. data/lib/templates/sphinx/sphinx.conf.erb +157 -0
  108. data/lib/templates/sphinx/sphinx.monitrc.erb +4 -0
  109. data/lib/templates/sphinx/sphinx_app.initd.centos.erb +90 -0
  110. data/lib/templates/sshd/sshd.monitrc.erb +5 -0
  111. data/script/destroy +14 -0
  112. data/script/generate +14 -0
  113. data/script/txt2html +80 -0
  114. data/setup.rb +1585 -0
  115. data/tasks/deployment.rake +34 -0
  116. data/tasks/environment.rake +7 -0
  117. data/tasks/website.rake +23 -0
  118. data/test/test_helper.rb +2 -0
  119. data/test/test_plugin_upload.rb +32 -0
  120. data/test/test_recipes.rb +37 -0
  121. data/test/test_templates.rb +29 -0
  122. metadata +198 -0
@@ -0,0 +1,27 @@
1
+ namespace :sshd do
2
+
3
+ namespace :monit do
4
+
5
+ desc <<-DESC
6
+ Install sshd monit hooks.
7
+
8
+ *sshd_port*: SSH daemon port. _Defaults to 22_\n
9
+ *sshd_pid_path*: Path to mysql pid file. _Defaults to /var/run/sshd.pid_\n
10
+ *monit_conf_dir*: Destination for monitrc. _Defaults to "/etc/monit"_\n
11
+
12
+ "Source":#{link_to_source(__FILE__)}
13
+ DESC
14
+ task :install do
15
+
16
+ # Settings
17
+ fetch_or_default(:sshd_port, 3306)
18
+ fetch_or_default(:sshd_pid_path, "/var/run/sshd.pid")
19
+ fetch_or_default(:monit_conf_dir, "/etc/monit")
20
+
21
+ put template.load("sshd/sshd.monitrc.erb", binding), "/tmp/sshd.monitrc"
22
+ run_via "install -o root /tmp/sshd.monitrc #{monit_conf_dir}/sshd.monitrc"
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,42 @@
1
+ # Mysql recipes
2
+ namespace :mysql do
3
+
4
+ desc <<-DESC
5
+ Create database, database user, and set grant permissions.
6
+
7
+ "Source":#{link_to_source(__FILE__)}
8
+ DESC
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: ')")
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
20
+ sql = template.load("mysql/install_db.sql.erb")
21
+
22
+ logger.trace "Running sql:\n#{sql}\n"
23
+
24
+ put sql, "/tmp/install_db_#{application}.sql"
25
+ run "mysql -u #{mysql_admin_user} -p#{mysql_admin_password} < /tmp/install_db_#{application}.sql"
26
+ utils.rm("/tmp/install_db_#{application}.sql")
27
+ end
28
+
29
+ desc <<-DESC
30
+ Create my.cnf based on template.
31
+
32
+ "Source":#{link_to_source(__FILE__)}
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)
37
+ task :install_my_cnf do
38
+ utils.install_template(my_cnf_template, "/etc/my.cnf")
39
+ end
40
+
41
+
42
+ end
@@ -0,0 +1,29 @@
1
+ # Nginx recipes
2
+ namespace :nginx do
3
+
4
+ namespace :host do
5
+
6
+ desc <<-DESC
7
+ Generate the nginx vhost include.
8
+
9
+ "Source":#{link_to_source(__FILE__)}
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")
19
+ task :setup do
20
+
21
+ set :nginx_upstream_ports, (0...nginx_upstream_size.to_i).collect { |i| nginx_upstream_port.to_i + i }
22
+ set :public_path, current_path + "/public"
23
+
24
+ utils.install_template(:nginx_vhost_template, "/etc/nginx/vhosts/#{nginx_upstream_name}.conf")
25
+ end
26
+
27
+ end
28
+
29
+ end
@@ -0,0 +1,71 @@
1
+ # Rails recipes
2
+ namespace :rails do
3
+
4
+ desc "Make symlink for database yaml"
5
+ task :update_code do
6
+ run "ln -nfs #{shared_path}/config/database.yml #{release_path}/config/database.yml"
7
+ end
8
+
9
+ # Log tasks
10
+ namespace :logs do
11
+
12
+ desc <<-DESC
13
+ Tail production log files.
14
+
15
+ "From errtheblog":http://errtheblog.com/posts/19-streaming-capistrano
16
+
17
+ "Source":#{link_to_source(__FILE__)}
18
+ DESC
19
+ task :tail, :roles => :web do
20
+ run "tail -f #{shared_path}/log/production.log" do |channel, stream, data|
21
+ puts # for an extra line break before the host name
22
+ puts "#{channel[:host]}: #{data}"
23
+ break if stream == :err
24
+ end
25
+ end
26
+
27
+
28
+ desc <<-DESC
29
+ Check production log files in TextMate.
30
+
31
+ "From errtheblog":http://errtheblog.com/posts/19-streaming-capistrano
32
+
33
+ "Source":#{link_to_source(__FILE__)}
34
+ DESC
35
+ task :mate, :roles => :app do
36
+
37
+ require 'tempfile'
38
+ tmp = Tempfile.open('w')
39
+ logs = Hash.new { |h,k| h[k] = '' }
40
+
41
+ run "tail -n500 #{shared_path}/log/production.log" do |channel, stream, data|
42
+ logs[channel[:host]] << data
43
+ break if stream == :err
44
+ end
45
+
46
+ logs.each do |host, log|
47
+ tmp.write("--- #{host} ---\n\n")
48
+ tmp.write(log + "\n")
49
+ end
50
+
51
+ exec "mate -w #{tmp.path}"
52
+ tmp.close
53
+ end
54
+ end
55
+
56
+ desc <<-DESC
57
+ Remotely console.
58
+
59
+ "From errtheblog":http://errtheblog.com/posts/19-streaming-capistrano
60
+
61
+ "Source":#{link_to_source(__FILE__)}
62
+ DESC
63
+ task :console, :roles => :app do
64
+ input = ''
65
+ run "cd #{current_path} && ./script/console #{ENV['RAILS_ENV']}" do |channel, stream, data|
66
+ next if data.chomp == input.chomp || data.chomp == ''
67
+ print data
68
+ channel.send_data(input = $stdin.gets) if data =~ /^(>|\?)>/
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,38 @@
1
+ namespace :redmine do
2
+
3
+ desc "Create necesary symlinks"
4
+ task :create_symlinks, :roles => :app do
5
+ # The redmine repository host a files directory, so I delete it
6
+ run "rm -rf #{release_path}/files"
7
+ run "ln -nfs #{shared_path}/files #{release_path}/files"
8
+ active_record.update_code
9
+ redmine.email.update_code
10
+ end
11
+
12
+ namespace :db do
13
+ desc "Execute plugin migrations"
14
+ task :migrate_plugins, :roles => :db do
15
+ rake.run("db:migrate_plugins")
16
+ end
17
+ end
18
+
19
+ namespace :email do
20
+ desc "Create Redmine email configuration."
21
+ task_arg(:mailserver_address, "Mailserver", :default => "localhost")
22
+ task_arg(:mailserver_port, "Mailserver port", :default => 25)
23
+ task_arg(:mail_domain, "Mail domain", :default => "example.com")
24
+ task_arg(:email_authentication, "Mailserver authentication method", :default => :plain)
25
+ task_arg(:mailserver_username, "Mailserver username", :default => "username")
26
+ task_arg(:mailserver_password, "Mailserver password", :default => "password")
27
+ task_arg(:mailserver_use_tls, "Mailserver use tls?", :default => false)
28
+ task :setup, :roles => :app do
29
+ run "mkdir -p #{shared_path}/config"
30
+ put template.load("redmine/email.yml.erb"), "#{shared_path}/config/email.yml"
31
+ end
32
+
33
+ desc "Make symlink for config/email.yml"
34
+ task :update_code, :roles => :app do
35
+ run "ln -nfs #{shared_path}/config/email.yml #{release_path}/config/email.yml"
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,60 @@
1
+ # Sphinx recipes
2
+ namespace :sphinx do
3
+
4
+ desc <<-DESC
5
+ Update sphinx conf for application.
6
+
7
+ "Source":#{link_to_source(__FILE__)}
8
+ DESC
9
+ task_arg(:sphinx_conf_template, "Path to sphinx.conf.erb template", :default => "config/templates/sphinx.conf.erb")
10
+ task_arg(:sphinx_port, "Sphinx port", :default => 3312)
11
+ task_arg(:sphinx_conf_path, "Path to sphinx.conf", :default => Proc.new {"#{shared_path}/config/sphinx.conf"}, :default_desc => "\#{shared_path}/config/sphinx.conf")
12
+ task_arg(:sphinx_conf_root, "Directory for sphinx configuration, like stopwords.txt", :default => Proc.new {"#{current_path}/config"}, :default_desc => "\#{current_path}/config")
13
+ task_arg(:sphinx_index_root, "Directory for sphinx indexes", :default => Proc.new {"#{shared_path}/var/index"}, :default_desc => "\#{shared_path}/var/index")
14
+ task_arg(:sphinx_log_root, "Directory for sphinx logs", :default => Proc.new {"#{shared_path}/log"}, :default_desc => "\#{shared_path}/log")
15
+ task_arg(:sphinx_pid_path, "Directory for sphinx pids", :default => Proc.new {"#{shared_path}/pids/searchd.pid"}, :default_desc => "\#{shared_path}/pids/searchd.pid")
16
+
17
+ task_arg(:sphinx_db_user, "Sphinx DB user", :set => :db_user)
18
+ task_arg(:sphinx_db_pass, "Sphinx DB password", :set => :db_pass)
19
+ task_arg(:sphinx_db_name, "Sphinx DB name", :set => :db_name)
20
+ task_arg(:sphinx_db_port, "Sphinx DB port", :set => :db_port)
21
+ task_arg(:sphinx_db_host, "Sphinx DB host", :set => :db_host)
22
+
23
+ task_arg(:sphinx_conf_host, "Sphinx DB host to listen on", :default => "127.0.0.1")
24
+ task :update_conf do
25
+ put(template.load(sphinx_conf_template), sphinx_conf_path)
26
+ end
27
+
28
+ desc "Make symlink for sphinx conf"
29
+ task :update_code do
30
+ run "ln -nfs #{shared_path}/config/sphinx.conf #{release_path}/config/sphinx.conf"
31
+ end
32
+
33
+ desc <<-DESC
34
+ Rotate sphinx index for application.
35
+
36
+ "Source":#{link_to_source(__FILE__)}
37
+ DESC
38
+ task_arg(:sphinx_prefix, :default => nil)
39
+ task_arg(:sphinx_conf, :default => Proc.new{"#{shared_path}/config/sphinx.conf"}, :default_desc => "\#{shared_path}/config/sphinx.conf")
40
+ task :rotate_all do
41
+ indexer_path = sphinx_prefix ? "#{sphinx_prefix}/bin/indexer" : "indexer"
42
+ run "#{indexer_path} --config #{sphinx_conf} --rotate --all"
43
+ end
44
+
45
+ desc <<-DESC
46
+ Build sphinx indexes for application.
47
+
48
+ *sphinx_prefix*<dd>Location to sphinx install. _Defaults to nil_\n
49
+ *sphinx_conf*<dd>Location to sphinx conf. _Defaults to "[shared_path]/config/sphinx.conf"_\n
50
+
51
+ "Source":#{link_to_source(__FILE__)}
52
+ DESC
53
+ task_arg(:sphinx_prefix, :default => nil)
54
+ task_arg(:sphinx_conf, :default => Proc.new{"#{shared_path}/config/sphinx.conf"}, :default_desc => "\#{shared_path}/config/sphinx.conf")
55
+ task :index_all do
56
+ indexer_path = sphinx_prefix ? "#{sphinx_prefix}/bin/indexer" : "indexer"
57
+ run "#{indexer_path} --config #{sphinx_conf} --all"
58
+ end
59
+
60
+ end
@@ -0,0 +1,47 @@
1
+ namespace :sshd do
2
+
3
+ desc <<-DESC
4
+ Create public and private keys for ssh.
5
+
6
+ "Source":#{link_to_source(__FILE__)}
7
+ DESC
8
+ task_arg(:ssh_keygen_type, "SSH keygen type", :default => "rsa")
9
+ task_arg(:ssh_keygen_bits, "SSH keygen bits", :default => 2048)
10
+ task :keygen do
11
+
12
+ run "ssh-keygen -t #{ssh_keygen_type} -b #{ssh_keygen_bits}" do |channel, stream, data|
13
+ logger.trace data
14
+
15
+ if data =~ /^Overwrite (y\/n)?/
16
+ channel.send_data "n\n"
17
+ logger.important "This key already exists! Aborting."
18
+
19
+ # Use default for file and empty password
20
+ elsif data =~ /^Enter file/ or
21
+ data =~ /^Enter passphrase/ or
22
+ data =~ /^Enter same passphrase again/
23
+
24
+ channel.send_data "\n"
25
+
26
+ end
27
+ end
28
+
29
+ end
30
+
31
+ desc <<-DESC
32
+ Add to authorized keys. Uses @.ssh/authorized_keys@.
33
+
34
+ "Source":#{link_to_source(__FILE__)}
35
+ DESC
36
+ task_arg(:ssh_public_key, "The public key from sshd:keygen")
37
+ task_arg(:ssh_dir, "SSH home directory", :default => "~/.ssh")
38
+ task_arg(:authorized_keys_path, "Path to authorized keys", :default => "~/.ssh/authorized_keys")
39
+ task :authorize_key do
40
+ run_all <<-CMDS
41
+ if [ ! -d #{ssh_dir} ]; then mkdir #{ssh_dir} ; chmod 700 #{ssh_dir} ; fi
42
+ if [ ! -f #{authorized_keys_path} ]; then touch #{authorized_keys_path} ; chmod 600 #{authorized_keys_path} ; fi
43
+ echo "#{ssh_public_key}" >> #{authorized_keys_path}
44
+ CMDS
45
+ end
46
+
47
+ end
@@ -0,0 +1,21 @@
1
+ namespace :syslogd do
2
+
3
+ desc <<-DESC
4
+ Add entry to syslog for application.
5
+
6
+ "Source":#{link_to_source(__FILE__)}
7
+ DESC
8
+ task_arg(:syslog_program_name, "Syslog program name. What you used for @SyslogLogger.new(\"program_name_here\")@")
9
+ task_arg(:syslog_log_path, "Path to log")
10
+ task_arg(:syslog_conf_path, :default => "/etc/syslog.conf")
11
+ task :setup_conf do
12
+
13
+ utils.append_to(syslog_conf_path, <<-DATA, "^!#{syslog_program_name}")
14
+
15
+ # Entry for #{syslog_program_name}
16
+ !#{syslog_program_name}
17
+ *.* #{syslog_log_path}
18
+ DATA
19
+ end
20
+
21
+ end
@@ -0,0 +1,46 @@
1
+ <VirtualHost *>
2
+ ServerName <%= domain %>
3
+ <%= server_alias %>
4
+ DocumentRoot <%= public_path %>
5
+
6
+ <Directory <%= public_path %>>
7
+ Options Indexes FollowSymLinks MultiViews
8
+ AllowOverride All
9
+ Order allow,deny
10
+ allow from all
11
+ </Directory>
12
+
13
+ RewriteEngine On
14
+
15
+ # Check for maintenance file and redirect all requests
16
+ RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
17
+ RewriteCond %{SCRIPT_FILENAME} !maintenance.html
18
+ RewriteRule ^.*$ /system/maintenance.html [L]
19
+
20
+ # Rewrite index to check for static
21
+ RewriteRule ^/$ /index.html [QSA]
22
+
23
+ # Rewrite to check for Rails cached page
24
+ RewriteRule ^([^.]+)$ $1.html [QSA]
25
+
26
+ # Redirect all non-static requests to cluster
27
+ RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
28
+ RewriteRule ^/(.*)$ balancer://<%= cluster_name %>%{REQUEST_URI} [P,QSA,L]
29
+
30
+ ProxyPassReverse / balancer://<%= cluster_name %>
31
+ ProxyPreserveHost on
32
+
33
+ #we need this as on Ubuntu by default Proxy is not allowed
34
+ <Proxy *>
35
+ Order allow,deny
36
+ Allow from all
37
+ </Proxy>
38
+
39
+ # Proxy balancer section (create one for each ruby app cluster)
40
+ <Proxy balancer://<%= cluster_name %>>
41
+ <% mongrel_instances.each do |mongrel_instance| %>
42
+ BalancerMember http://<%= mongrel_instance %>
43
+ <% end %>
44
+ </Proxy>
45
+
46
+ </VirtualHost>
@@ -0,0 +1,54 @@
1
+ #! /bin/sh
2
+ # backgroundjob_<%= application %>: Backgroundjob daemon for <%= application %>
3
+ #
4
+ # chkconfig: - 86 14
5
+ # description: backgroundjob daemon
6
+ # processname: bj
7
+ #
8
+ # Author: Gabriel Handford http://ducktyper.com
9
+
10
+ # Source function library
11
+ . /etc/rc.d/init.d/functions
12
+
13
+ RETVAL=0
14
+
15
+ DESC="backgroundjob daemon (<%= application %>)"
16
+ BIN_PATH="<%= backgroundjob_bin_path %>"
17
+ PID_FILE="<%= backgroundjob_pid_path %>"
18
+
19
+ start() {
20
+ echo -n $"Starting $DESC: "
21
+ daemon --user sick $BIN_PATH
22
+ RETVAL=$?
23
+ echo
24
+ return $RETVAL;
25
+ }
26
+
27
+ stop() {
28
+ echo -n $"Stopping $DESC:"
29
+ killproc -p $PID_FILE
30
+ RETVAL=$?
31
+ echo
32
+ return $RETVAL;
33
+ }
34
+
35
+ case "$1" in
36
+ start)
37
+ start
38
+ ;;
39
+ stop)
40
+ stop
41
+ ;;
42
+ restart)
43
+ stop
44
+ sleep 1
45
+ start
46
+ RETVAL=$?;
47
+ ;;
48
+ *)
49
+ echo "Usage: $0 {start|stop|restart}" >&2
50
+ RETVAL=3;
51
+ ;;
52
+ esac
53
+
54
+ exit $RETVAL;