rubber 1.3.2 → 1.5.0
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 +7 -0
- data/VERSION +1 -1
- data/bin/vulcanize +16 -32
- data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +6 -6
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +2 -2
- data/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +3 -0
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +29 -16
- data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +1 -1
- data/generators/vulcanize/templates/base/Rakefile +21 -0
- data/generators/vulcanize/templates/base/config/rubber/common/crontab +6 -1
- data/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +2 -2
- data/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +3 -4
- data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +27 -48
- data/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
- data/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +25 -0
- data/generators/vulcanize/templates/base/config/rubber/rubber.yml +7 -12
- data/generators/vulcanize/templates/base/script/cron-runner +1 -1
- data/generators/vulcanize/templates/base/templates.rb +9 -0
- data/generators/vulcanize/templates/base/templates.yml +5 -0
- data/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
- data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +58 -0
- data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
- data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
- data/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
- data/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
- data/generators/vulcanize/templates/cassandra/templates.yml +1 -0
- data/generators/vulcanize/templates/{complete_passenger_mysql → complete_passenger}/config/rubber/role/haproxy/haproxy-passenger.conf +1 -1
- data/generators/vulcanize/templates/{complete_passenger_mysql → complete_passenger}/config/rubber/rubber-complete.yml +0 -0
- data/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
- data/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
- data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +1 -7
- data/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
- data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +3 -3
- data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +1 -1
- data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +5 -5
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +2 -2
- data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +1 -1
- data/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +4 -4
- data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +1 -1
- data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +4 -4
- data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +2 -0
- data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +3 -3
- data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +2 -2
- data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +1 -1
- data/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +4 -2
- data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +4 -4
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +2 -2
- data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +1 -0
- data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +1 -1
- data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +6 -8
- data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +1 -0
- data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +24 -109
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +1 -1
- data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +2 -2
- data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +1 -1
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +19 -15
- data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +2 -2
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +2 -2
- data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +3 -3
- data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +5 -5
- data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +2 -2
- data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +10 -1
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +1 -1
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +2 -2
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +1 -1
- data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +3 -3
- data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +2 -2
- data/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
- data/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
- data/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
- data/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
- data/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
- data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
- data/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
- data/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
- data/generators/vulcanize/templates/postgresql/templates.yml +1 -0
- data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +8 -7
- data/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
- data/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
- data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +46 -27
- data/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
- data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
- data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +14 -6
- data/generators/vulcanize/templates/resque/script/resque_worker_management.rb +112 -0
- data/generators/vulcanize/templates/resque/templates.rb +1 -0
- data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +7 -8
- data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +7 -4
- data/generators/vulcanize/vulcanize_generator.rb +154 -49
- data/lib/generators/vulcanize/USAGE +6 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +8 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +79 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +34 -0
- data/lib/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +6 -0
- data/lib/generators/vulcanize/templates/apache/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/base/Capfile +14 -0
- data/lib/generators/vulcanize/templates/base/Rakefile +21 -0
- data/lib/generators/vulcanize/templates/base/config/deploy.rb +55 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/common/crontab +22 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +8 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +13 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +63 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/deploy-util.rb +97 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +78 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/rubber-rvm.yml +25 -0
- data/lib/generators/vulcanize/templates/base/config/rubber/rubber.yml +235 -0
- data/lib/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
- data/lib/generators/vulcanize/templates/base/script/cron-rake +18 -0
- data/lib/generators/vulcanize/templates/base/script/cron-runner +18 -0
- data/lib/generators/vulcanize/templates/base/script/cron-sh +67 -0
- data/lib/generators/vulcanize/templates/base/templates.rb +9 -0
- data/lib/generators/vulcanize/templates/base/templates.yml +6 -0
- data/lib/generators/vulcanize/templates/cassandra/config/rubber/deploy-cassandra.rb +88 -0
- data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.in.sh +58 -0
- data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/cassandra.yaml +210 -0
- data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/log4j-server.properties +45 -0
- data/lib/generators/vulcanize/templates/cassandra/config/rubber/role/cassandra/monit-cassandra.conf +8 -0
- data/lib/generators/vulcanize/templates/cassandra/config/rubber/rubber-cassandra.yml +18 -0
- data/lib/generators/vulcanize/templates/cassandra/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
- data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
- data/lib/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
- data/lib/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
- data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
- data/lib/generators/vulcanize/templates/complete_passenger/config/rubber/rubber-complete.yml +40 -0
- data/lib/generators/vulcanize/templates/complete_passenger/templates.rb +9 -0
- data/lib/generators/vulcanize/templates/complete_passenger/templates.yml +9 -0
- data/lib/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +4 -0
- data/lib/generators/vulcanize/templates/complete_passenger_postgresql/templates.yml +4 -0
- data/lib/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
- data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
- data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
- data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
- data/lib/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
- data/lib/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
- data/lib/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
- data/lib/generators/vulcanize/templates/cruise/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +11 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +21 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
- data/lib/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
- data/lib/generators/vulcanize/templates/haproxy/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +59 -0
- data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh +589 -0
- data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml +199 -0
- data/lib/generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf +9 -0
- data/lib/generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml +10 -0
- data/lib/generators/vulcanize/templates/jetty/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
- data/lib/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
- data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
- data/lib/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
- data/lib/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
- data/lib/generators/vulcanize/templates/memcached/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
- data/lib/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
- data/lib/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
- data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
- data/lib/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
- data/lib/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
- data/lib/generators/vulcanize/templates/mongrel/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
- data/lib/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +252 -0
- data/lib/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +33 -0
- data/lib/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
- data/lib/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
- data/lib/generators/vulcanize/templates/monit/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +11 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +81 -0
- data/lib/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
- data/lib/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +55 -0
- data/lib/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
- data/lib/generators/vulcanize/templates/munin/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +12 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +169 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/apparmor-mysql.conf +46 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +163 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
- data/lib/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +47 -0
- data/lib/generators/vulcanize/templates/mysql/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +177 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
- data/lib/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
- data/lib/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
- data/lib/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
- data/lib/generators/vulcanize/templates/nginx/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +46 -0
- data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +34 -0
- data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +7 -0
- data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
- data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
- data/lib/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +35 -0
- data/lib/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +15 -0
- data/lib/generators/vulcanize/templates/passenger/templates.yml +3 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/common/database.yml +12 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/deploy-postgresql.rb +131 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/crontab +14 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/monit-postgresql.conf +10 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/pg_hba.conf +89 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql-sysctl.conf +6 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/role/db/postgresql.conf +504 -0
- data/lib/generators/vulcanize/templates/postgresql/config/rubber/rubber-postgresql.yml +45 -0
- data/lib/generators/vulcanize/templates/postgresql/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +37 -0
- data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/crontab +8 -0
- data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/monit-redis.conf +9 -0
- data/lib/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +141 -0
- data/lib/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +4 -0
- data/lib/generators/vulcanize/templates/redis/templates.yml +1 -0
- data/lib/generators/vulcanize/templates/resque/config/initializers/resque.rb +15 -0
- data/lib/generators/vulcanize/templates/resque/config/rubber/common/resque.yml +5 -0
- data/lib/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +58 -0
- data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf +14 -0
- data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_worker/monit-resque_worker.conf +19 -0
- data/lib/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +18 -0
- data/lib/generators/vulcanize/templates/resque/script/resque_worker_management.rb +112 -0
- data/lib/generators/vulcanize/templates/resque/templates.rb +1 -0
- data/lib/generators/vulcanize/templates/resque/templates.yml +3 -0
- data/lib/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
- data/lib/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
- data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
- data/lib/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +13 -0
- data/lib/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
- data/lib/generators/vulcanize/templates/sphinx/templates.yml +1 -0
- data/lib/generators/vulcanize/vulcanize_generator.rb +172 -0
- data/lib/rubber.rb +42 -6
- data/lib/rubber/cloud/aws.rb +4 -0
- data/lib/rubber/dns/zerigo.rb +9 -3
- data/lib/rubber/environment.rb +1 -1
- data/lib/rubber/generator.rb +8 -8
- data/lib/rubber/instance.rb +1 -1
- data/lib/rubber/railtie.rb +14 -0
- data/lib/rubber/recipes/rubber.rb +6 -0
- data/lib/rubber/recipes/rubber/deploy.rb +3 -3
- data/lib/rubber/recipes/rubber/setup.rb +22 -17
- data/lib/rubber/recipes/rubber/utils.rb +37 -14
- data/lib/rubber/util.rb +36 -1
- data/rails/init.rb +1 -4
- metadata +244 -35
- data/generators/vulcanize/templates/resque/config/rubber/deploy-resque-worker-default.rb +0 -38
- data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker_default/monit-resque_worker_default.conf +0 -19
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
|
|
2
|
+
# REQUIRED: The credentials for creating/accessong your app's database
|
|
3
|
+
#
|
|
4
|
+
db_user: "#{app_name[0,16]}"
|
|
5
|
+
db_pass:
|
|
6
|
+
db_name: "#{app_name}_#{RUBBER_ENV}"
|
|
7
|
+
|
|
8
|
+
db_slave_user: "#{('slave_' + db_user)[0,16]}"
|
|
9
|
+
db_replicator_user: "#{('replicator_' + db_user)[0,16]}"
|
|
10
|
+
|
|
11
|
+
# REQUIRED: The command to use to do a full backup of your database using
|
|
12
|
+
# "rake rubber:backup_db"
|
|
13
|
+
db_backup_cmd: "nice sudo -u postgres pg_dumpall -U postgres | gzip -c > %backup_file%"
|
|
14
|
+
|
|
15
|
+
# REQUIRED: The command to use to restore the database using
|
|
16
|
+
# "rake rubber:restore_db_s3"
|
|
17
|
+
# This command will receive the data generated by db_backup_cmd via
|
|
18
|
+
# its standard input
|
|
19
|
+
db_restore_cmd: "zcat - | psql -Uroot -h %host% %name%"
|
|
20
|
+
|
|
21
|
+
postgresql_ver: 8.4
|
|
22
|
+
postgresql_conf_dir: "/etc/postgresql/#{postgresql_ver}/main"
|
|
23
|
+
postgresql_data_dir: /mnt/postgresql/data
|
|
24
|
+
postgresql_archive_dir: /mnt/postgresql/archive
|
|
25
|
+
postgresql_pid_file: "/var/run/postgresql/#{postgresql_ver}-main.pid"
|
|
26
|
+
postgresql_ctl: "/usr/sbin/service postgresql-#{postgresql_ver}"
|
|
27
|
+
|
|
28
|
+
# Capistrano needs db:primary role for migrate to work,
|
|
29
|
+
# so we might as well just make consistent across the board
|
|
30
|
+
role_dependencies:
|
|
31
|
+
postgresql_master: [db:primary=true]
|
|
32
|
+
postgresql_slave: [db]
|
|
33
|
+
db:primary=true: [postgresql_master]
|
|
34
|
+
db: [postgresql_slave]
|
|
35
|
+
|
|
36
|
+
packages: [postgresql-client, libpq-dev]
|
|
37
|
+
gems: [pg]
|
|
38
|
+
|
|
39
|
+
roles:
|
|
40
|
+
postgresql_master:
|
|
41
|
+
db_server_id: 1
|
|
42
|
+
postgresql_slave:
|
|
43
|
+
db_server_id: 2
|
|
44
|
+
db:
|
|
45
|
+
packages: [postgresql]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
description: The PostgreSQL database system
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
namespace :rubber do
|
|
2
|
+
|
|
3
|
+
namespace :redis do
|
|
4
|
+
|
|
5
|
+
rubber.allow_optional_tasks(self)
|
|
6
|
+
|
|
7
|
+
after "rubber:install_packages", "rubber:redis:custom_install"
|
|
8
|
+
|
|
9
|
+
task :custom_install, :roles => :redis do
|
|
10
|
+
custom_package('http://ftp.us.debian.org/debian/pool/main/r/redis/', 'redis-server', '1.2.6-1', '! -x /usr/bin/redis-server')
|
|
11
|
+
# force redis config regen so db dir gets recreated when creating staging from a bundle
|
|
12
|
+
rsudo "rm -f /etc/redis/redis.conf"
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
desc "Stops the redis server"
|
|
16
|
+
task :stop, :roles => :redis do
|
|
17
|
+
rsudo "/etc/init.d/redis-server stop; exit 0"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
desc "Starts the redis server"
|
|
21
|
+
task :start, :roles => :redis do
|
|
22
|
+
rsudo "/etc/init.d/redis-server start"
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
desc "Restarts the redis server"
|
|
26
|
+
task :restart, :roles => :redis do
|
|
27
|
+
rsudo "/etc/init.d/redis-server restart"
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
desc "Reloads the redis server"
|
|
31
|
+
task :reload, :roles => :redis do
|
|
32
|
+
rsudo "/etc/init.d/redis-server restart"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@read_cmd = 'crontab -l'
|
|
3
|
+
@write_cmd = 'crontab -'
|
|
4
|
+
@additive = ['# start-redis-crontab', '# end-redis-crontab']
|
|
5
|
+
%>
|
|
6
|
+
|
|
7
|
+
# backup redis DBs every hour
|
|
8
|
+
0 * * * * BACKUP_DIR=/mnt/redis_backups BACKUP_NAME=redis BACKUP_CMD="tar -czf \%dir\%/redis_\%time_stamp\%.tgz <%= rubber_env.redis_db_dir %>" <%= RUBBER_ROOT %>/script/cron-rake rubber:backup
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = '/etc/monit/monit.d/monit-redis.conf'
|
|
3
|
+
%>
|
|
4
|
+
<% PIDFILE = "/var/run/redis.pid" %>
|
|
5
|
+
check process redis with pidfile <%= PIDFILE %>
|
|
6
|
+
group redis-<%= RUBBER_ENV %>
|
|
7
|
+
start program = "/etc/init.d/redis-server start"
|
|
8
|
+
stop program = "/etc/init.d/redis-server stop"
|
|
9
|
+
if failed host <%= rubber_env.host %> port 6379 with timeout 10 seconds for 10 cycles then restart
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = '/etc/redis/redis.conf'
|
|
3
|
+
@post = <<-SCRIPT
|
|
4
|
+
mkdir -p #{rubber_env.redis_db_dir}
|
|
5
|
+
chown -R redis:redis #{rubber_env.redis_db_dir}
|
|
6
|
+
/etc/init.d/redis-server restart
|
|
7
|
+
SCRIPT
|
|
8
|
+
%>
|
|
9
|
+
|
|
10
|
+
# Redis configuration file example
|
|
11
|
+
|
|
12
|
+
# By default Redis does not run as a daemon. Use 'yes' if you need it.
|
|
13
|
+
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
|
|
14
|
+
daemonize yes
|
|
15
|
+
|
|
16
|
+
# When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
|
|
17
|
+
# You can specify a custom pid file location here.
|
|
18
|
+
pidfile /var/run/redis.pid
|
|
19
|
+
|
|
20
|
+
# Accept connections on the specified port, default is 6379
|
|
21
|
+
port 6379
|
|
22
|
+
|
|
23
|
+
# If you want you can bind a single interface, if the bind option is not
|
|
24
|
+
# specified all the interfaces will listen for connections.
|
|
25
|
+
#
|
|
26
|
+
# bind 127.0.0.1
|
|
27
|
+
|
|
28
|
+
# Close the connection after a client is idle for N seconds (0 to disable)
|
|
29
|
+
timeout 300
|
|
30
|
+
|
|
31
|
+
# Save the DB on disk:
|
|
32
|
+
#
|
|
33
|
+
# save <seconds> <changes>
|
|
34
|
+
#
|
|
35
|
+
# Will save the DB if both the given number of seconds and the given
|
|
36
|
+
# number of write operations against the DB occurred.
|
|
37
|
+
#
|
|
38
|
+
# In the example below the behaviour will be to save:
|
|
39
|
+
# after 900 sec (15 min) if at least 1 key changed
|
|
40
|
+
# after 300 sec (5 min) if at least 10 keys changed
|
|
41
|
+
# after 60 sec if at least 10000 keys changed
|
|
42
|
+
save 900 1
|
|
43
|
+
save 300 10
|
|
44
|
+
save 60 10000
|
|
45
|
+
|
|
46
|
+
# The filename where to dump the DB
|
|
47
|
+
dbfilename dump.rdb
|
|
48
|
+
|
|
49
|
+
# For default save/load DB in/from the working directory
|
|
50
|
+
# Note that you must specify a directory not a file name.
|
|
51
|
+
dir <%= rubber_env.redis_db_dir %>
|
|
52
|
+
|
|
53
|
+
# Set server verbosity to 'debug'
|
|
54
|
+
# it can be one of:
|
|
55
|
+
# debug (a lot of information, useful for development/testing)
|
|
56
|
+
# notice (moderately verbose, what you want in production probably)
|
|
57
|
+
# warning (only very important / critical messages are logged)
|
|
58
|
+
loglevel notice
|
|
59
|
+
|
|
60
|
+
# Specify the log file name. Also 'stdout' can be used to force
|
|
61
|
+
# the demon to log on the standard output. Note that if you use standard
|
|
62
|
+
# output for logging but daemonize, logs will be sent to /dev/null
|
|
63
|
+
logfile /var/log/redis/redis-server.log
|
|
64
|
+
|
|
65
|
+
# Set the number of databases. The default database is DB 0, you can select
|
|
66
|
+
# a different one on a per-connection basis using SELECT <dbid> where
|
|
67
|
+
# dbid is a number between 0 and 'databases'-1
|
|
68
|
+
databases 16
|
|
69
|
+
|
|
70
|
+
################################# REPLICATION #################################
|
|
71
|
+
|
|
72
|
+
# Master-Slave replication. Use slaveof to make a Redis instance a copy of
|
|
73
|
+
# another Redis server. Note that the configuration is local to the slave
|
|
74
|
+
# so for example it is possible to configure the slave to save the DB with a
|
|
75
|
+
# different interval, or to listen to another port, and so on.
|
|
76
|
+
|
|
77
|
+
# slaveof <masterip> <masterport>
|
|
78
|
+
|
|
79
|
+
################################## SECURITY ###################################
|
|
80
|
+
|
|
81
|
+
# Require clients to issue AUTH <PASSWORD> before processing any other
|
|
82
|
+
# commands. This might be useful in environments in which you do not trust
|
|
83
|
+
# others with access to the host running redis-server.
|
|
84
|
+
#
|
|
85
|
+
# This should stay commented out for backward compatibility and because most
|
|
86
|
+
# people do not need auth (e.g. they run their own servers).
|
|
87
|
+
|
|
88
|
+
# requirepass foobared
|
|
89
|
+
|
|
90
|
+
################################### LIMITS ####################################
|
|
91
|
+
|
|
92
|
+
# Set the max number of connected clients at the same time. By default there
|
|
93
|
+
# is no limit, and it's up to the number of file descriptors the Redis process
|
|
94
|
+
# is able to open. The special value '0' means no limts.
|
|
95
|
+
# Once the limit is reached Redis will close all the new connections sending
|
|
96
|
+
# an error 'max number of clients reached'.
|
|
97
|
+
|
|
98
|
+
# maxclients 128
|
|
99
|
+
|
|
100
|
+
# Don't use more memory than the specified amount of bytes.
|
|
101
|
+
# When the memory limit is reached Redis will try to remove keys with an
|
|
102
|
+
# EXPIRE set. It will try to start freeing keys that are going to expire
|
|
103
|
+
# in little time and preserve keys with a longer time to live.
|
|
104
|
+
# Redis will also try to remove objects from free lists if possible.
|
|
105
|
+
#
|
|
106
|
+
# If all this fails, Redis will start to reply with errors to commands
|
|
107
|
+
# that will use more memory, like SET, LPUSH, and so on, and will continue
|
|
108
|
+
# to reply to most read-only commands like GET.
|
|
109
|
+
#
|
|
110
|
+
# WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
|
|
111
|
+
# 'state' server or cache, not as a real DB. When Redis is used as a real
|
|
112
|
+
# database the memory usage will grow over the weeks, it will be obvious if
|
|
113
|
+
# it is going to use too much memory in the long run, and you'll have the time
|
|
114
|
+
# to upgrade. With maxmemory after the limit is reached you'll start to get
|
|
115
|
+
# errors for write operations, and this may even lead to DB inconsistency.
|
|
116
|
+
|
|
117
|
+
# maxmemory <bytes>
|
|
118
|
+
|
|
119
|
+
############################### ADVANCED CONFIG ###############################
|
|
120
|
+
|
|
121
|
+
# Glue small output buffers together in order to send small replies in a
|
|
122
|
+
# single TCP packet. Uses a bit more CPU but most of the times it is a win
|
|
123
|
+
# in terms of number of queries per second. Use 'yes' if unsure.
|
|
124
|
+
glueoutputbuf yes
|
|
125
|
+
|
|
126
|
+
# Use object sharing. Can save a lot of memory if you have many common
|
|
127
|
+
# string in your dataset, but performs lookups against the shared objects
|
|
128
|
+
# pool so it uses more CPU and can be a bit slower. Usually it's a good
|
|
129
|
+
# idea.
|
|
130
|
+
#
|
|
131
|
+
# When object sharing is enabled (shareobjects yes) you can use
|
|
132
|
+
# shareobjectspoolsize to control the size of the pool used in order to try
|
|
133
|
+
# object sharing. A bigger pool size will lead to better sharing capabilities.
|
|
134
|
+
# In general you want this value to be at least the double of the number of
|
|
135
|
+
# very common strings you have in your dataset.
|
|
136
|
+
#
|
|
137
|
+
# WARNING: object sharing is experimental, don't enable this feature
|
|
138
|
+
# in production before of Redis 1.0-stable. Still please try this feature in
|
|
139
|
+
# your development environment so that we can test it better.
|
|
140
|
+
shareobjects no
|
|
141
|
+
shareobjectspoolsize 1024
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
description: The redis module
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'yaml'
|
|
2
|
+
require 'resque'
|
|
3
|
+
|
|
4
|
+
rails_root = ENV['RAILS_ROOT'] || File.dirname(__FILE__) + '/../..'
|
|
5
|
+
rails_env = ENV['RAILS_ENV'] || 'development'
|
|
6
|
+
|
|
7
|
+
redis_host = 'localhost:6379'
|
|
8
|
+
|
|
9
|
+
resque_yml = rails_root + '/config/resque.yml'
|
|
10
|
+
if File.exist? resque_yml
|
|
11
|
+
resque_config = YAML.load_file(resque_yml)
|
|
12
|
+
redis_host = resque_config[rails_env]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
Resque.redis = redis_host
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
|
|
2
|
+
namespace :rubber do
|
|
3
|
+
|
|
4
|
+
namespace :resque do
|
|
5
|
+
|
|
6
|
+
rubber.allow_optional_tasks(self)
|
|
7
|
+
|
|
8
|
+
namespace :worker do
|
|
9
|
+
|
|
10
|
+
rubber.allow_optional_tasks(self)
|
|
11
|
+
|
|
12
|
+
before "deploy:stop", "rubber:resque:worker:stop"
|
|
13
|
+
after "deploy:start", "rubber:resque:worker:start"
|
|
14
|
+
after "deploy:restart", "rubber:resque:worker:restart"
|
|
15
|
+
|
|
16
|
+
desc "Starts resque workers"
|
|
17
|
+
task :start, :roles => :resque_worker do
|
|
18
|
+
rsudo "cd #{current_path} && RUBBER_ENV=#{rails_env} ./script/resque_worker_management.rb start", :as => rubber_env.app_user
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
desc "Stops resque workers"
|
|
22
|
+
task :stop, :roles => :resque_worker do
|
|
23
|
+
rsudo "cd #{current_path} && RUBBER_ENV=#{rails_env} ./script/resque_worker_management.rb stop", :as => rubber_env.app_user
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
desc "Restarts resque workers"
|
|
27
|
+
task :restart, :roles => :resque_worker do
|
|
28
|
+
rsudo "cd #{current_path} && RUBBER_ENV=#{rails_env} ./script/resque_worker_management.rb restart", :as => rubber_env.app_user
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
namespace :web do
|
|
33
|
+
rubber.allow_optional_tasks(self)
|
|
34
|
+
|
|
35
|
+
before "deploy:stop", "rubber:resque:web:stop"
|
|
36
|
+
after "deploy:start", "rubber:resque:web:start"
|
|
37
|
+
after "deploy:restart", "rubber:resque:web:restart"
|
|
38
|
+
|
|
39
|
+
desc "Starts resque web tools"
|
|
40
|
+
task :start, :roles => :resque_web do
|
|
41
|
+
rsudo "RAILS_ENV=#{RUBBER_ENV} resque-web --pid-file /var/run/resque_web.pid --port #{rubber_env.resque_web_port} --no-launch #{current_path}/config/initializers/resque.rb"
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
desc "Stops resque web tools"
|
|
45
|
+
task :stop, :roles => :resque_web do
|
|
46
|
+
rsudo "RAILS_ENV=#{RUBBER_ENV} resque-web --pid-file /var/run/resque_web.pid --kill"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
desc "Restarts resque web tools"
|
|
50
|
+
task :restart, :roles => :resque_web do
|
|
51
|
+
rubber.resque.web.stop
|
|
52
|
+
rubber.resque.web.start
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/generators/vulcanize/templates/resque/config/rubber/role/resque_web/monit-resque_web.conf
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = '/etc/monit/monit.d/monit-resque_web.conf'
|
|
3
|
+
|
|
4
|
+
PIDFILE = "/var/run/resque_web.pid"
|
|
5
|
+
start_program = "HOME=/root resque-web --pid-file #{PIDFILE} --port #{rubber_env.resque_web_port} --no-launch #{RUBBER_ROOT}/config/initializers/resque.rb"
|
|
6
|
+
stop_program = "HOME=/root resque-web --pid-file #{PIDFILE} --kill"
|
|
7
|
+
%>
|
|
8
|
+
|
|
9
|
+
check process resque_web with pidfile <%= PIDFILE %>
|
|
10
|
+
group resque_web
|
|
11
|
+
start program = "bash -l -c '<%= start_program %>'"
|
|
12
|
+
stop program = "bash -l -c '<%= stop_program %>'"
|
|
13
|
+
|
|
14
|
+
if totalmem > 350.0 MB for 15 cycles then restart
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%
|
|
2
|
+
@path = '/etc/monit/monit.d/monit-resque_worker.conf'
|
|
3
|
+
%>
|
|
4
|
+
|
|
5
|
+
<% rubber_env.resque_workers.each_with_index do |worker, i| %>
|
|
6
|
+
<%
|
|
7
|
+
PIDFILE = "#{RUBBER_ROOT}/tmp/pids/resque_worker_#{i}.pid"
|
|
8
|
+
|
|
9
|
+
start_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb start #{i}"
|
|
10
|
+
stop_program = "cd #{RUBBER_ROOT} && ./script/resque_worker_management.rb stop #{i}"
|
|
11
|
+
%>
|
|
12
|
+
|
|
13
|
+
check process resque_worker_<%= i %> with pidfile <%= PIDFILE %>
|
|
14
|
+
group resque_worker
|
|
15
|
+
start program = "/usr/bin/sudo -H -u <%= rubber_env.app_user %> bash -l -c '<%= start_program %>'"
|
|
16
|
+
stop program = "/usr/bin/sudo -H -u <%= rubber_env.app_user %> bash -l -c '<%= stop_program %>'"
|
|
17
|
+
|
|
18
|
+
if totalmem > 350.0 MB for 15 cycles then restart
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
resque_web_port: 5678
|
|
2
|
+
|
|
3
|
+
# list of workers with the queues to be run on each - on each worker instance,
|
|
4
|
+
# a worker is run for each item in this list to handle the queues specified
|
|
5
|
+
#
|
|
6
|
+
resque_workers:
|
|
7
|
+
-
|
|
8
|
+
queues: *
|
|
9
|
+
poll_interval: 1
|
|
10
|
+
-
|
|
11
|
+
queues: *
|
|
12
|
+
poll_interval: 1
|
|
13
|
+
|
|
14
|
+
gems: [yajl-ruby resque]
|
|
15
|
+
|
|
16
|
+
role_dependencies:
|
|
17
|
+
web_tools: [resque_web]
|
|
18
|
+
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
env = ENV["RUBBER_ENV"] ||= "development"
|
|
4
|
+
root = File.join(File.dirname(__FILE__), '..')
|
|
5
|
+
rails_env_file = File.join(root, 'config', 'environment.rb')
|
|
6
|
+
|
|
7
|
+
if File.exists? rails_env_file
|
|
8
|
+
require(rails_env_file)
|
|
9
|
+
else
|
|
10
|
+
require "rubber"
|
|
11
|
+
Rubber::initialize(root, env)
|
|
12
|
+
require 'resque'
|
|
13
|
+
require "#{root}/config/initializers/resque.rb"
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def start_all(workers)
|
|
17
|
+
puts "Starting all workers"
|
|
18
|
+
workers.each_with_index do |worker, i|
|
|
19
|
+
start(worker, i)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def start(worker, index)
|
|
24
|
+
puts "Starting worker #{index}/#{worker.queues}"
|
|
25
|
+
|
|
26
|
+
log_file = log_file(index)
|
|
27
|
+
pid_file = pid_file(index)
|
|
28
|
+
|
|
29
|
+
queues = worker.queues.to_s.split(',')
|
|
30
|
+
|
|
31
|
+
daemonize(log_file, pid_file) do
|
|
32
|
+
resque_worker = Resque::Worker.new(*queues)
|
|
33
|
+
resque_worker.verbose = ENV['LOGGING'] || ENV['VERBOSE']
|
|
34
|
+
resque_worker.very_verbose = ENV['VVERBOSE']
|
|
35
|
+
|
|
36
|
+
puts "*** Starting worker #{resque_worker}"
|
|
37
|
+
resque_worker.work(worker.poll_interval.to_i || 5) # interval, will block
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def stop_all(workers)
|
|
42
|
+
puts "Stopping all workers"
|
|
43
|
+
workers.size.times do |i|
|
|
44
|
+
stop(i)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def stop(index)
|
|
49
|
+
puts "Stopping worker #{index}"
|
|
50
|
+
|
|
51
|
+
pid_file = pid_file(index)
|
|
52
|
+
pid = File.read(pid_file).to_i rescue nil
|
|
53
|
+
if pid
|
|
54
|
+
puts "Killing worker #{index}: pid #{pid}"
|
|
55
|
+
begin
|
|
56
|
+
Process.kill("QUIT", pid)
|
|
57
|
+
rescue Exception => e
|
|
58
|
+
puts e
|
|
59
|
+
end
|
|
60
|
+
File.delete(pid_file) if File.exist?(pid_file)
|
|
61
|
+
else
|
|
62
|
+
puts "No pid file for worker #{index}: #{pid_file}"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def daemonize(log_file, pid_file)
|
|
67
|
+
return if fork
|
|
68
|
+
Process::setsid
|
|
69
|
+
exit!(0) if fork
|
|
70
|
+
Dir::chdir("/")
|
|
71
|
+
File.umask 0000
|
|
72
|
+
FileUtils.touch log_file
|
|
73
|
+
STDIN.reopen log_file
|
|
74
|
+
STDOUT.reopen log_file, "a"
|
|
75
|
+
STDERR.reopen log_file, "a"
|
|
76
|
+
|
|
77
|
+
File.open(pid_file, 'w') {|f| f.write("#{Process.pid}") }
|
|
78
|
+
|
|
79
|
+
yield if block_given?
|
|
80
|
+
exit(0)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def pid_file(index)
|
|
84
|
+
File.expand_path "#{Rubber.root}/tmp/pids/resque_worker_#{index}.pid"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def log_file(index)
|
|
88
|
+
File.expand_path "#{Rubber.root}/log/resque_worker_#{index}.log"
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
action = ARGV[0]
|
|
92
|
+
worker_index = ARGV[1] ? ARGV[1].to_i : nil
|
|
93
|
+
if action.nil? || ! %w[start stop restart].include?(action)
|
|
94
|
+
puts "Usage: script/resque_worker_management.rb [start|stop|restart]"
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
workers = Rubber.config.resque_workers
|
|
98
|
+
|
|
99
|
+
case action
|
|
100
|
+
when 'start'
|
|
101
|
+
worker_index ? start(workers[worker_index], worker_index) : start_all(workers)
|
|
102
|
+
when 'stop'
|
|
103
|
+
worker_index ? stop(worker_index) : stop_all(workers)
|
|
104
|
+
when 'restart'
|
|
105
|
+
if worker_index
|
|
106
|
+
stop(worker_index)
|
|
107
|
+
start(workers[worker_index], worker_index)
|
|
108
|
+
else
|
|
109
|
+
stop_all(workers)
|
|
110
|
+
start_all(workers)
|
|
111
|
+
end
|
|
112
|
+
end
|