nirvdrum-rubber 1.1.7

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 (186) hide show
  1. data/CHANGELOG +146 -0
  2. data/COPYING +339 -0
  3. data/README +6 -0
  4. data/TODO +11 -0
  5. data/VERSION +1 -0
  6. data/bin/vulcanize +41 -0
  7. data/generators/vulcanize/USAGE +6 -0
  8. data/generators/vulcanize/templates/apache/config/rubber/deploy-apache.rb +51 -0
  9. data/generators/vulcanize/templates/apache/config/rubber/role/apache/deflate.conf +10 -0
  10. data/generators/vulcanize/templates/apache/config/rubber/role/apache/expires.conf +9 -0
  11. data/generators/vulcanize/templates/apache/config/rubber/role/apache/headers.conf +6 -0
  12. data/generators/vulcanize/templates/apache/config/rubber/role/apache/monit-apache.conf +8 -0
  13. data/generators/vulcanize/templates/apache/config/rubber/role/apache/ports.conf +5 -0
  14. data/generators/vulcanize/templates/apache/config/rubber/role/apache/setenvif.conf +52 -0
  15. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache-vhost.conf +66 -0
  16. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-apache.auth +7 -0
  17. data/generators/vulcanize/templates/apache/config/rubber/role/web_tools/tools-index.html +34 -0
  18. data/generators/vulcanize/templates/apache/config/rubber/rubber-apache.yml +6 -0
  19. data/generators/vulcanize/templates/apache/templates.yml +1 -0
  20. data/generators/vulcanize/templates/base/Capfile +14 -0
  21. data/generators/vulcanize/templates/base/config/deploy.rb +55 -0
  22. data/generators/vulcanize/templates/base/config/rubber/common/crontab +17 -0
  23. data/generators/vulcanize/templates/base/config/rubber/common/monit-postfix.conf +8 -0
  24. data/generators/vulcanize/templates/base/config/rubber/common/rubber.profile +14 -0
  25. data/generators/vulcanize/templates/base/config/rubber/deploy-setup.rb +84 -0
  26. data/generators/vulcanize/templates/base/config/rubber/rubber-dns.yml +79 -0
  27. data/generators/vulcanize/templates/base/config/rubber/rubber.yml +227 -0
  28. data/generators/vulcanize/templates/base/lib/tasks/rubber.rake +15 -0
  29. data/generators/vulcanize/templates/base/script/cron-rake +18 -0
  30. data/generators/vulcanize/templates/base/script/cron-runner +18 -0
  31. data/generators/vulcanize/templates/base/script/cron-sh +67 -0
  32. data/generators/vulcanize/templates/base/templates.yml +1 -0
  33. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/haproxy/haproxy-mongrel.conf +23 -0
  34. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/role/nginx/nginx-mongrel.conf +113 -0
  35. data/generators/vulcanize/templates/complete_mongrel_mysql/config/rubber/rubber-complete.yml +41 -0
  36. data/generators/vulcanize/templates/complete_mongrel_mysql/templates.yml +6 -0
  37. data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/role/haproxy/haproxy-passenger.conf +21 -0
  38. data/generators/vulcanize/templates/complete_passenger_mysql/config/rubber/rubber-complete.yml +40 -0
  39. data/generators/vulcanize/templates/complete_passenger_mysql/templates.yml +10 -0
  40. data/generators/vulcanize/templates/cruise/config/rubber/deploy-cruise.rb +72 -0
  41. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/cruise +40 -0
  42. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/my.cnf +165 -0
  43. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/production.rb +8 -0
  44. data/generators/vulcanize/templates/cruise/config/rubber/role/cruise/site_config.rb +76 -0
  45. data/generators/vulcanize/templates/cruise/config/rubber/role/web_tools/cruise-nginx.conf +11 -0
  46. data/generators/vulcanize/templates/cruise/config/rubber/rubber-cruise.yml +18 -0
  47. data/generators/vulcanize/templates/cruise/templates.yml +1 -0
  48. data/generators/vulcanize/templates/haproxy/config/rubber/deploy-haproxy.rb +45 -0
  49. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-base.conf +26 -0
  50. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/haproxy-default.conf +8 -0
  51. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/monit-haproxy.conf +9 -0
  52. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslog-haproxy.conf +6 -0
  53. data/generators/vulcanize/templates/haproxy/config/rubber/role/haproxy/syslogd-default.conf +17 -0
  54. data/generators/vulcanize/templates/haproxy/config/rubber/role/web_tools/haproxy-nginx.conf +10 -0
  55. data/generators/vulcanize/templates/haproxy/config/rubber/rubber-haproxy.yml +7 -0
  56. data/generators/vulcanize/templates/haproxy/templates.yml +1 -0
  57. data/generators/vulcanize/templates/jetty/config/rubber/deploy-jetty.rb +59 -0
  58. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.sh +589 -0
  59. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/jetty.xml +199 -0
  60. data/generators/vulcanize/templates/jetty/config/rubber/role/jetty/monit-jetty.conf +9 -0
  61. data/generators/vulcanize/templates/jetty/config/rubber/rubber-jetty.yml +10 -0
  62. data/generators/vulcanize/templates/jetty/templates.yml +1 -0
  63. data/generators/vulcanize/templates/memcached/config/memcached.yml +28 -0
  64. data/generators/vulcanize/templates/memcached/config/rubber/common/memcached.yml +14 -0
  65. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached.conf +52 -0
  66. data/generators/vulcanize/templates/memcached/config/rubber/role/memcached/memcached_munin_plugin +249 -0
  67. data/generators/vulcanize/templates/memcached/config/rubber/rubber-memcached.yml +7 -0
  68. data/generators/vulcanize/templates/memcached/templates.yml +1 -0
  69. data/generators/vulcanize/templates/minimal_mysql/templates.yml +7 -0
  70. data/generators/vulcanize/templates/minimal_nodb/templates.yml +6 -0
  71. data/generators/vulcanize/templates/mongrel/config/rubber/deploy-mongrel.rb +75 -0
  72. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/mongrel_cluster.yml +12 -0
  73. data/generators/vulcanize/templates/mongrel/config/rubber/role/mongrel/monit-mongrel.conf +20 -0
  74. data/generators/vulcanize/templates/mongrel/config/rubber/rubber-mongrel.yml +9 -0
  75. data/generators/vulcanize/templates/mongrel/templates.yml +1 -0
  76. data/generators/vulcanize/templates/monit/config/rubber/common/monit-default.conf +15 -0
  77. data/generators/vulcanize/templates/monit/config/rubber/common/monit.conf +251 -0
  78. data/generators/vulcanize/templates/monit/config/rubber/deploy-monit.rb +32 -0
  79. data/generators/vulcanize/templates/monit/config/rubber/role/web_tools/monit-admin-nginx.conf +10 -0
  80. data/generators/vulcanize/templates/monit/config/rubber/rubber-monit.yml +6 -0
  81. data/generators/vulcanize/templates/monit/templates.yml +1 -0
  82. data/generators/vulcanize/templates/munin/config/rubber/common/monit-munin.conf +8 -0
  83. data/generators/vulcanize/templates/munin/config/rubber/common/munin-node.conf +48 -0
  84. data/generators/vulcanize/templates/munin/config/rubber/common/munin-plugins.conf +9 -0
  85. data/generators/vulcanize/templates/munin/config/rubber/deploy-munin.rb +46 -0
  86. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-nginx.conf +8 -0
  87. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin-plugins.conf +31 -0
  88. data/generators/vulcanize/templates/munin/config/rubber/role/web_tools/munin.conf +80 -0
  89. data/generators/vulcanize/templates/munin/config/rubber/rubber-munin.yml +8 -0
  90. data/generators/vulcanize/templates/munin/script/munin/example_mysql_query.rb +57 -0
  91. data/generators/vulcanize/templates/munin/script/munin/example_simple.rb +24 -0
  92. data/generators/vulcanize/templates/munin/templates.yml +1 -0
  93. data/generators/vulcanize/templates/mysql/config/rubber/common/database.yml +11 -0
  94. data/generators/vulcanize/templates/mysql/config/rubber/deploy-mysql.rb +156 -0
  95. data/generators/vulcanize/templates/mysql/config/rubber/role/db/crontab +14 -0
  96. data/generators/vulcanize/templates/mysql/config/rubber/role/db/monit-mysql.cnf +10 -0
  97. data/generators/vulcanize/templates/mysql/config/rubber/role/db/my.cnf +167 -0
  98. data/generators/vulcanize/templates/mysql/config/rubber/role/mysql_slave/mysql_slave_munin_plugin +51 -0
  99. data/generators/vulcanize/templates/mysql/config/rubber/rubber-mysql.yml +46 -0
  100. data/generators/vulcanize/templates/mysql/templates.yml +1 -0
  101. data/generators/vulcanize/templates/mysql_cluster/config/rubber/common/mysql_cluster_migrations.rb +13 -0
  102. data/generators/vulcanize/templates/mysql_cluster/config/rubber/deploy-mysql_cluster.rb +173 -0
  103. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_data/my.cnf +15 -0
  104. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_mgm/ndb_mgmd.cnf +39 -0
  105. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/monit-mysql_cluster_sql.cnf +10 -0
  106. data/generators/vulcanize/templates/mysql_cluster/config/rubber/role/mysql_sql/my.cnf +23 -0
  107. data/generators/vulcanize/templates/mysql_cluster/config/rubber/rubber-mysql_cluster.yml +32 -0
  108. data/generators/vulcanize/templates/mysql_cluster/templates.yml +1 -0
  109. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/database.yml +16 -0
  110. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/monit-mysql_proxy.cnf +10 -0
  111. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy +153 -0
  112. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.conf +10 -0
  113. data/generators/vulcanize/templates/mysql_proxy/config/rubber/common/mysql-proxy.lua +5 -0
  114. data/generators/vulcanize/templates/mysql_proxy/config/rubber/deploy-mysql_proxy.rb +52 -0
  115. data/generators/vulcanize/templates/mysql_proxy/config/rubber/rubber-mysql_proxy.yml +11 -0
  116. data/generators/vulcanize/templates/mysql_proxy/templates.yml +1 -0
  117. data/generators/vulcanize/templates/nginx/config/rubber/deploy-nginx.rb +45 -0
  118. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/crontab +9 -0
  119. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/monit-nginx.conf +8 -0
  120. data/generators/vulcanize/templates/nginx/config/rubber/role/nginx/nginx.conf +42 -0
  121. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/nginx-tools.conf +55 -0
  122. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-index.html +30 -0
  123. data/generators/vulcanize/templates/nginx/config/rubber/role/web_tools/tools-nginx.auth +7 -0
  124. data/generators/vulcanize/templates/nginx/config/rubber/rubber-nginx.yml +10 -0
  125. data/generators/vulcanize/templates/nginx/templates.yml +1 -0
  126. data/generators/vulcanize/templates/passenger/config/rubber/deploy-passenger.rb +37 -0
  127. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-memory.conf +34 -0
  128. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger-sudoers.conf +7 -0
  129. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/munin-passenger.conf +47 -0
  130. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger-apache-vhost.conf +46 -0
  131. data/generators/vulcanize/templates/passenger/config/rubber/role/passenger/passenger.conf +10 -0
  132. data/generators/vulcanize/templates/passenger/config/rubber/rubber-passenger.yml +15 -0
  133. data/generators/vulcanize/templates/passenger/templates.yml +3 -0
  134. data/generators/vulcanize/templates/redis/config/rubber/deploy-redis.rb +36 -0
  135. data/generators/vulcanize/templates/redis/config/rubber/role/redis/crontab +8 -0
  136. data/generators/vulcanize/templates/redis/config/rubber/role/redis/monit-redis.conf +9 -0
  137. data/generators/vulcanize/templates/redis/config/rubber/role/redis/redis.conf +141 -0
  138. data/generators/vulcanize/templates/redis/config/rubber/rubber-redis.yml +4 -0
  139. data/generators/vulcanize/templates/redis/templates.yml +1 -0
  140. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque-worker-default.rb +38 -0
  141. data/generators/vulcanize/templates/resque/config/rubber/deploy-resque.rb +39 -0
  142. data/generators/vulcanize/templates/resque/config/rubber/role/resque_worker_default/monit-resque_worker_default.conf +19 -0
  143. data/generators/vulcanize/templates/resque/config/rubber/rubber-resque.yml +10 -0
  144. data/generators/vulcanize/templates/resque/templates.yml +3 -0
  145. data/generators/vulcanize/templates/sphinx/config/rubber/common/sphinx.yml +46 -0
  146. data/generators/vulcanize/templates/sphinx/config/rubber/deploy-sphinx.rb +112 -0
  147. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/crontab +11 -0
  148. data/generators/vulcanize/templates/sphinx/config/rubber/role/sphinx/monit-sphinx.conf +10 -0
  149. data/generators/vulcanize/templates/sphinx/config/rubber/rubber-sphinx.yml +6 -0
  150. data/generators/vulcanize/templates/sphinx/templates.yml +1 -0
  151. data/generators/vulcanize/vulcanize_generator.rb +67 -0
  152. data/lib/capistrano/hostcmd.rb +12 -0
  153. data/lib/rubber.rb +38 -0
  154. data/lib/rubber/capistrano.rb +1 -0
  155. data/lib/rubber/cloud.rb +13 -0
  156. data/lib/rubber/cloud/aws.rb +334 -0
  157. data/lib/rubber/cloud/base.rb +16 -0
  158. data/lib/rubber/configuration.rb +47 -0
  159. data/lib/rubber/dns.rb +13 -0
  160. data/lib/rubber/dns/base.rb +84 -0
  161. data/lib/rubber/dns/dyndns.rb +78 -0
  162. data/lib/rubber/dns/nettica.rb +117 -0
  163. data/lib/rubber/dns/zerigo.rb +174 -0
  164. data/lib/rubber/environment.rb +169 -0
  165. data/lib/rubber/generator.rb +197 -0
  166. data/lib/rubber/instance.rb +166 -0
  167. data/lib/rubber/recipes/rubber.rb +89 -0
  168. data/lib/rubber/recipes/rubber/bundles.rb +28 -0
  169. data/lib/rubber/recipes/rubber/deploy.rb +90 -0
  170. data/lib/rubber/recipes/rubber/instances.rb +393 -0
  171. data/lib/rubber/recipes/rubber/load_balancers.rb +44 -0
  172. data/lib/rubber/recipes/rubber/security_groups.rb +189 -0
  173. data/lib/rubber/recipes/rubber/setup.rb +457 -0
  174. data/lib/rubber/recipes/rubber/spot_requests.rb +17 -0
  175. data/lib/rubber/recipes/rubber/static_ips.rb +107 -0
  176. data/lib/rubber/recipes/rubber/utils.rb +203 -0
  177. data/lib/rubber/recipes/rubber/volumes.rb +264 -0
  178. data/lib/rubber/tasks/rubber.rb +279 -0
  179. data/lib/rubber/util.rb +37 -0
  180. data/rails/init.rb +9 -0
  181. data/test/environment_test.rb +133 -0
  182. data/test/generator_test.rb +323 -0
  183. data/test/instance_test.rb +93 -0
  184. data/test/test_helper.rb +8 -0
  185. data/test/util_test.rb +16 -0
  186. metadata +298 -0
@@ -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,4 @@
1
+
2
+ redis_db_dir: /mnt/redis
3
+
4
+ gems: [redis]
@@ -0,0 +1 @@
1
+ description: The redis module
@@ -0,0 +1,38 @@
1
+ namespace :rubber do
2
+
3
+ namespace :resque_worker_default do
4
+
5
+ rubber.allow_optional_tasks(self)
6
+
7
+ before "deploy:stop", "rubber:resque_worker_default:stop"
8
+ after "deploy:start", "rubber:resque_worker_default:start"
9
+ after "deploy:restart", "rubber:resque_worker_default:restart"
10
+
11
+ desc "Starts default resque worker"
12
+ task :start, :roles => :resque_worker_default do
13
+ as = fetch(:runner, "app")
14
+ via = fetch(:run_method, :sudo)
15
+ rubber_env.resque_worker_default_count.times do |i|
16
+ invoke_command "sh -c 'cd #{current_path}; RAILS_ENV=#{rails_env} QUEUE=* nohup rake resque:work &> log/resque_worker_default_#{i}.log & echo $! > tmp/pids/resque_worker_default_#{i}.pid'", :via => via, :as => as
17
+ end
18
+ end
19
+
20
+ desc "Stops default resque worker"
21
+ task :stop, :roles => :resque_worker_default do
22
+ as = fetch(:runner, "app")
23
+ via = fetch(:run_method, :sudo)
24
+ rubber_env.resque_worker_default_count.times do |i|
25
+ invoke_command "sh -c 'cd #{current_path} && kill `cat tmp/pids/resque_worker_default_#{i}.pid` && rm -f tmp/pids/resque_worker_default_#{i}.pid; exit 0;'", :via => via, :as => as
26
+ end
27
+
28
+ sleep 11 #wait for process to finish
29
+ end
30
+
31
+ desc "Restarts default resque worker"
32
+ task :restart, :roles => :resque_worker_default do
33
+ rubber.resque_worker_default.stop
34
+ rubber.resque_worker_default.start
35
+ end
36
+ end
37
+
38
+ end
@@ -0,0 +1,39 @@
1
+
2
+ namespace :rubber do
3
+
4
+ namespace :resque do
5
+
6
+ rubber.allow_optional_tasks(self)
7
+
8
+ after "rubber:install_packages", "rubber:resque:custom_install"
9
+
10
+ task :custom_install, :roles => :resque do
11
+ rubber.sudo_script 'install_resque', <<-ENDSCRIPT
12
+ if [ -d resque ]; then
13
+ rm -r resque
14
+ fi
15
+
16
+ git clone git://github.com/defunkt/resque.git
17
+
18
+ if [ -d #{rubber_env.resque_web_dir} ]; then
19
+ rm -r #{rubber_env.resque_web_dir}
20
+ fi
21
+
22
+ mkdir -p #{rubber_env.resque_web_dir}
23
+ mkdir #{rubber_env.resque_web_dir}/tmp
24
+ mv resque/config.ru #{rubber_env.resque_web_dir}
25
+ mv resque/lib/resque/server/* #{rubber_env.resque_web_dir}/
26
+
27
+ rm -f /var/www/resque
28
+ ln -s #{rubber_env.resque_web_dir}/public /var/www/resque
29
+ ENDSCRIPT
30
+ end
31
+
32
+ after "rubber:setup_app_permissions", "rubber:resque:setup_resque_permissions"
33
+
34
+ task :setup_resque_permissions, :roles => :resque do
35
+ run "chown -R #{rubber_env.app_user}:#{rubber_env.app_user} #{rubber_env.resque_web_dir}/config.ru"
36
+ end
37
+
38
+ end
39
+ end
@@ -0,0 +1,19 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-resque_worker_default.conf'
3
+ %>
4
+
5
+ <% rubber_env.resque_worker_default_count.times do |i| %>
6
+ <%
7
+ PIDFILE = "#{RUBBER_ROOT}/tmp/pids/resque_worker_default_#{i}.pid"
8
+
9
+ start_program = "/usr/bin/sudo -u #{rubber_env.app_user} sh -c 'cd #{RUBBER_ROOT}; RAILS_ENV=#{RUBBER_ENV} QUEUE=* nohup rake resque:work &> log/resque_worker_default_#{i}.log & echo $! > tmp/pids/resque_worker_default_#{i}.pid'"
10
+ stop_program = "/usr/bin/sudo -u #{rubber_env.app_user} sh -c 'cd #{RUBBER_ROOT} && kill `cat tmp/pids/resque_worker_default_#{i}.pid` && rm -f tmp/pids/resque_worker_default_#{i}.pid'"
11
+ %>
12
+
13
+ check process resque_worker_default_<%= i %> with pidfile <%= PIDFILE %>
14
+ group resque_worker_default
15
+ start program = "<%= start_program %>"
16
+ stop program = "<%= stop_program %>"
17
+
18
+ if totalmem > 200.0 MB for 5 cycles then restart
19
+ <% end %>
@@ -0,0 +1,10 @@
1
+ resque_web_dir: /opt/resque
2
+
3
+ resque_worker_default_count: 5
4
+
5
+ role_dependencies:
6
+ css_validator: [redis]
7
+
8
+ roles:
9
+ resque:
10
+ gems: [redis redis-namespace yajl-ruby sinatra resque]
@@ -0,0 +1,3 @@
1
+ description: The resque background queue system
2
+ dependent_templates:
3
+ - redis
@@ -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
@@ -0,0 +1,11 @@
1
+ <%
2
+ @read_cmd = 'crontab -l'
3
+ @write_cmd = 'crontab -'
4
+ @additive = ["# rubber-sphinx-start", "# rubber-sphinx-end"]
5
+ %>
6
+
7
+ # incremental index once every 10 minutes
8
+ */10 * * * * sudo -u <%= rubber_env.app_user %> <%= RUBBER_ROOT %>/script/cron-rake RUBBER_ENV=<%= RUBBER_ENV %> ts:in:delta
9
+
10
+ # full reindex daily at 4:35
11
+ 35 4 * * * sudo -u <%= rubber_env.app_user %> <%= RUBBER_ROOT %>/script/cron-rake RUBBER_ENV=<%= RUBBER_ENV %> ts:index
@@ -0,0 +1,10 @@
1
+ <%
2
+ @path = '/etc/monit/monit.d/monit-sphinx.conf'
3
+ %>
4
+
5
+ check process sphinx with pidfile <%= RUBBER_ROOT %>/log/searchd.<%= RUBBER_ENV %>.pid
6
+ group sphinx-<%= RUBBER_ENV %>
7
+ start program = "/usr/bin/sudo -u rails sh -c 'cd <%= RUBBER_ROOT %> && PATH=<%= rubber_env.ruby_prefix %>/bin:/usr/local/bin:$PATH RAILS_ENV=<%= RUBBER_ENV %> rake ts:start'"
8
+ stop program = "/usr/bin/sudo -u rails sh -c 'cd <%= RUBBER_ROOT %> && PATH=<%= rubber_env.ruby_prefix %>/bin:/usr/local/bin:$PATH RAILS_ENV=<%= RUBBER_ENV %> rake ts:stop'"
9
+ if failed host <%= rubber_env.host %> port 3312 with timeout 5 seconds for 5 cycles then restart
10
+