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,3 @@
1
+ check process backgroundjob_<%= application %> with pidfile <%= backgroundjob_pid_path %>
2
+ start program = "/sbin/service backgroundjob_<%= application %> start"
3
+ stop program = "/sbin/service backgroundjob_<%= application %> stop"
@@ -0,0 +1,58 @@
1
+ #! /bin/sh
2
+ # backgroundrb_<%= application %>: Backgroundrb daemon for <%= application %>
3
+ #
4
+ # chkconfig: - 86 14
5
+ # description: backgroundrb daemon
6
+ # processname: backgroundrb
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="backgroundrb daemon (<%= application %>)"
16
+ DAEMON="<%= backgroundrb_bin_path %>"
17
+ PIDFILE="<%= backgroundrb_pid_path %>"
18
+
19
+ # For stop/reload support using patched backgroundrb that takes
20
+ # pidfile as argument into backgroundrb.yml config.
21
+
22
+ start() {
23
+ daemon --user <%= user %> --pidfile $PIDFILE $DAEMON
24
+ RETVAL=$?
25
+ echo
26
+ return $RETVAL;
27
+ }
28
+
29
+ stop() {
30
+ kill -QUIT `cat $PIDFILE` || echo -n " not running"
31
+ }
32
+
33
+ case "$1" in
34
+ start)
35
+ echo -n "Starting $DESC: $NAME"
36
+ start
37
+ RETVAL=$?;
38
+ ;;
39
+ stop)
40
+ echo -n "Stopping $DESC: $NAME"
41
+ stop
42
+ RETVAL=$?;
43
+ ;;
44
+ restart)
45
+ echo -n "Restarting $DESC: $NAME"
46
+ stop
47
+ # Sleep after stop
48
+ sleep 1
49
+ start
50
+ RETVAL=$?;
51
+ ;;
52
+ *)
53
+ echo "Usage: $0 {start|stop|restart}" >&2
54
+ RETVAL=3;
55
+ ;;
56
+ esac
57
+
58
+ exit $RETVAL;
@@ -0,0 +1,3 @@
1
+ check process backgroundrb_<%= application %> with pidfile <%= backgroundrb_pid_path %>
2
+ start program = "/sbin/service backgroundrb_<%= application %> start"
3
+ stop program = "/sbin/service backgroundrb_<%= application %> stop"
@@ -0,0 +1,14 @@
1
+ ---
2
+ :backgroundrb:
3
+ :port: <%= backgroundrb_port %>
4
+ :ip: <%= backgroundrb_host %>
5
+ :pid_file: "<%= backgroundrb_pid_path %>"
6
+
7
+
8
+ :development:
9
+ :backgroundrb:
10
+ :log: foreground
11
+
12
+ :production:
13
+ :backgroundrb:
14
+ :lazy_load: true
@@ -0,0 +1,22 @@
1
+ #
2
+ # This file is auto-generated from Capitate
3
+ #
4
+ require 'capitate'
5
+
6
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
7
+
8
+ set :project_root, File.dirname(__FILE__)
9
+
10
+ # Load capitate recipes
11
+ require 'capitate/recipes'
12
+
13
+ # Load recipes from plugins
14
+ Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
15
+
16
+ # Load project recipes
17
+ Dir['lib/recipes/*.rb'].each { |plugin| load(plugin) }
18
+
19
+ require 'erb'
20
+
21
+ # Load more cap files
22
+ # load "config/deployment/install-centos.rb"
@@ -0,0 +1,3 @@
1
+ <%= logrotate_log_path %> {
2
+ <%= logrotate_options_text %>
3
+ }
@@ -0,0 +1,58 @@
1
+ #! /bin/sh
2
+ # memcached: Memcached
3
+ #
4
+ # chkconfig: - 86 14
5
+ # description: memcached
6
+ # processname: memcached
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="memcached"
16
+ NAME="memcached"
17
+ DAEMON=/usr/local/bin/memcached
18
+ PIDFILE=<%= memcached_pid_path %>
19
+ MEM=<%= memcached_memory %>
20
+ PORT=<%= memcached_port %>
21
+ # Have to be root in order to save in /var/run
22
+ USER=root
23
+
24
+ start() {
25
+ echo -n $"Starting $DESC: "
26
+ daemon $DAEMON -d -m $MEM -p $PORT -u $USER -P $PIDFILE
27
+ RETVAL=$?
28
+ echo
29
+ return $RETVAL;
30
+ }
31
+
32
+ stop() {
33
+ echo -n $"Stopping $DESC: "
34
+ killproc -p $PIDFILE memcached
35
+ RETVAL=$?
36
+ echo
37
+ return $RETVAL;
38
+ }
39
+
40
+ case "$1" in
41
+ start)
42
+ start
43
+ ;;
44
+ stop)
45
+ stop
46
+ ;;
47
+ restart)
48
+ stop
49
+ sleep 1
50
+ start
51
+ ;;
52
+ *)
53
+ echo "Usage: $0 {start|stop|restart}" >&2
54
+ RETVAL=3;
55
+ ;;
56
+ esac
57
+
58
+ exit $RETVAL;
@@ -0,0 +1,4 @@
1
+ check process memcached with pidfile <%= memcached_pid_path %>
2
+ start program = "/sbin/service memcached start"
3
+ stop program = "/sbin/service memcached stop"
4
+ if failed host 127.0.0.1 port <%= memcached_port %> then restart
@@ -0,0 +1,14 @@
1
+ defaults:
2
+ ttl: <%= memcached_ttl %>
3
+ readonly: <%= memcached_readonly.to_s %>
4
+ urlencode: <%= memcached_urlencode.to_s %>
5
+ c_threshold: <%= memcached_c_threshold %>
6
+ compression: <%= memcached_compression.to_s %>
7
+ debug: <%= memcached_debug.to_s %>
8
+ namespace: <%= memcached_namespace %>
9
+
10
+ development:
11
+ servers: localhost:11211
12
+
13
+ production:
14
+ servers: <%= memcached_servers.inspect %>
@@ -0,0 +1,13 @@
1
+ <% processes.each do |process| %>
2
+
3
+ check process <%= merb_application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
4
+ group <%= merb_application %>
5
+ start program = "<%= process[:start] %>"
6
+ stop program = "<%= process[:stop] %>"
7
+ if totalmem > 100 Mb then restart
8
+ if cpu is greater than 60% for 2 cycles then alert
9
+ if cpu > 80% for 5 cycles then restart
10
+ if loadavg(5min) greater than 10 for 8 cycles then restart
11
+ if 3 restarts within 5 cycles then timeout
12
+
13
+ <% end %>
@@ -0,0 +1,123 @@
1
+ #!/bin/sh
2
+ #
3
+ # Copyright (c) 2008 Gabriel Handford, gabrielh@gmail.com
4
+ #
5
+ # merb_<%= application %> Startup script for Merb (<%= application %>)
6
+ #
7
+ # chkconfig: - 85 15
8
+ # description: merb_<%= application %> Merb runtime for <%= application %>
9
+ #
10
+ # WARNING: Relies on some patches:
11
+ # This requires a couple of submitted patches to merb-core (on version 0.9.2),
12
+ # for correct pid file and kill handling.
13
+ #
14
+ # Also have to cd into the project before starting merb. There are some issues with plugins
15
+ # and Merb.root
16
+ #
17
+
18
+ # Source function library
19
+ . /etc/rc.d/init.d/functions
20
+
21
+ RETVAL=0
22
+
23
+ NAME="merb_<%= application %>"
24
+ USER="<%= user %>"
25
+ GROUP="<%= user %>"
26
+
27
+ PID_PATH="<%= merb_pid_path %>"
28
+ NODES=<%= merb_nodes %>
29
+ PORT=<%= merb_port %>
30
+ ROOT_DIR="<%= merb_root %>"
31
+
32
+ CMD="<%= merb_command_path %>"
33
+ CMD_OPTIONS="-u $USER -G $GROUP -P $PID_PATH -m $ROOT_DIR -e production"
34
+
35
+ RETVAL=0
36
+
37
+ start() {
38
+ echo -n $"Starting $NAME: "
39
+ cd $ROOT_DIR
40
+ daemon --user $USER $CMD $CMD_OPTIONS -c $NODES -p $PORT
41
+ RETVAL=$?
42
+ [ "$RETVAL" -eq 0 ] && success $"$NAME start" || failure $"$NAME start"
43
+ echo
44
+ return $RETVAL;
45
+ }
46
+
47
+ # Start only a single daemon function ($1=port)
48
+ start_only() {
49
+ cd $ROOT_DIR
50
+ daemon --user $USER $CMD $CMD_OPTIONS -c 1 -p $1
51
+ }
52
+
53
+ stop() {
54
+ echo -n $"Stopping $NAME: "
55
+ cd $ROOT_DIR
56
+ $CMD $CMD_OPTIONS -c $NODES -p $PORT -K all
57
+ RETVAL=$?
58
+ [ "$RETVAL" -eq 0 ] && success $"$NAME shutdown" || failure $"$NAME shutdown"
59
+ echo
60
+ return $RETVAL;
61
+ }
62
+
63
+ # Stop only a single daemon ($1=port)
64
+ stop_only() {
65
+ cd $ROOT_DIR
66
+ $CMD $CMD_OPTIONS -c 1 -p $PORT -K $1
67
+ }
68
+
69
+ restart() {
70
+ stop
71
+ sleep 1
72
+ start
73
+ }
74
+
75
+ status() {
76
+ echo "Don't know"
77
+ RETVAL=$?
78
+ echo
79
+ return $RETVAL;
80
+ }
81
+
82
+ fail() {
83
+ echo "Failed to start: $1"
84
+ exit 1
85
+ }
86
+
87
+ # Gracefully exit if the controller is missing.
88
+ which $CMD >/dev/null || fail "$CMD not found"
89
+
90
+ case "$1" in
91
+ start)
92
+ start
93
+ ;;
94
+ start_only)
95
+ start_only $2
96
+ ;;
97
+ stop)
98
+ stop
99
+ ;;
100
+ stop_only)
101
+ stop_only $2
102
+ ;;
103
+ restart)
104
+ restart
105
+ ;;
106
+ status)
107
+ status
108
+ ;;
109
+ *)
110
+ echo "Usage: $0"
111
+ echo " "
112
+ echo " start"
113
+ echo " stop"
114
+ echo " restart"
115
+ echo " status"
116
+ echo " start_only [port]"
117
+ echo " stop_only [port]"
118
+ echo " "
119
+ RETVAL=3;
120
+ ;;
121
+ esac
122
+
123
+ exit $RETVAL
@@ -0,0 +1,15 @@
1
+ <% processes.each do |process| %>
2
+
3
+ check process <%= merb_application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
4
+ group <%= merb_application %>
5
+ start program = "<%= process[:start] %>"
6
+ stop program = "<%= process[:stop] %>"
7
+ if failed host 127.0.0.1 port <%= process[:port] %> protocol http
8
+ and request "/" then alert
9
+ if totalmem > 100 Mb then restart
10
+ if cpu is greater than 60% for 2 cycles then alert
11
+ if cpu > 80% for 5 cycles then restart
12
+ if loadavg(5min) greater than 10 for 8 cycles then restart
13
+ if 3 restarts within 5 cycles then timeout
14
+
15
+ <% end %>
@@ -0,0 +1,94 @@
1
+ #!/bin/bash
2
+ #
3
+ # Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
4
+ #
5
+ # mongrel_cluster_<%= application %> Startup script for Mongrel clusters (<%= application %>)
6
+ #
7
+ # chkconfig: - 85 15
8
+ # description: mongrel_cluster_<%= application %> manages multiple Mongrel processes for use \
9
+ # behind a load balancer.
10
+ #
11
+ # Modified by: Gabriel Handford http://ducktyper.com
12
+ #
13
+
14
+ # Source function library
15
+ . /etc/rc.d/init.d/functions
16
+
17
+ RETVAL=0
18
+
19
+ NAME="mongrel_cluster_<%= application %>"
20
+ CONF_DIR=<%= mongrel_config_dir %>
21
+ PID_DIR=<%= mongrel_pid_dir %>
22
+ USER=<%= user %>
23
+ CMD=<%= mongrel_cluster_command %>
24
+
25
+ RETVAL=0
26
+
27
+ start() {
28
+ echo -n $"Starting $NAME: "
29
+ $CMD start -c $CONF_DIR --clean >/dev/null
30
+ RETVAL=$?
31
+ [ "$RETVAL" -eq 0 ] && success $"$NAME start" || failure $"$NAME start"
32
+ echo
33
+ return $RETVAL;
34
+ }
35
+
36
+ stop() {
37
+ echo -n $"Stopping $NAME: "
38
+ $CMD stop -c $CONF_DIR >/dev/null
39
+ RETVAL=$?
40
+ [ "$RETVAL" -eq 0 ] && success $"$NAME shutdown" || failure $"$NAME shutdown"
41
+ echo
42
+ return $RETVAL;
43
+ }
44
+
45
+ restart() {
46
+ echo -n $"Restarting $NAME: "
47
+ $CMD restart -c $CONF_DIR >/dev/null
48
+ RETVAL=$?
49
+ [ "$RETVAL" -eq 0 ] && success $"$NAME restart" || failure $"$NAME restart"
50
+ echo
51
+ return $RETVAL;
52
+ }
53
+
54
+ status() {
55
+ $CMD status -c $CONF_DIR
56
+ RETVAL=$?
57
+ echo
58
+ return $RETVAL;
59
+ }
60
+
61
+ fail() {
62
+ echo "Failed to start: $1"
63
+ exit 1
64
+ }
65
+
66
+ # Gracefully exit if the controller is missing.
67
+ which $CMD >/dev/null || fail "$CMD not found"
68
+
69
+ # Go no further if config directory is missing.
70
+ [ -d "$CONF_DIR" ] || fail "$CONF_DIR not found"
71
+
72
+ # Go no further if config directory is missing.
73
+ [ -d "$PID_DIR" ] || fail "$PID_DIR not found"
74
+
75
+ case "$1" in
76
+ start)
77
+ start
78
+ ;;
79
+ stop)
80
+ stop
81
+ ;;
82
+ restart)
83
+ restart
84
+ ;;
85
+ status)
86
+ status
87
+ ;;
88
+ *)
89
+ echo "Usage: $0 {start|stop|restart|status}"
90
+ RETVAL=3;
91
+ ;;
92
+ esac
93
+
94
+ exit $RETVAL
@@ -0,0 +1,15 @@
1
+ <% processes.each do |process| %>
2
+
3
+ check process <%= mongrel_application %>_<%= process[:port] %> with pidfile <%= process[:pid_path] %>
4
+ group <%= mongrel_application %>
5
+ start program = "<%= process[:name] %> start <%= process[:start_options] %>"
6
+ stop program = "<%= process[:name] %> stop <%= process[:stop_options] %>"
7
+ if failed host 127.0.0.1 port <%= process[:port] %> protocol http
8
+ and request "/" then alert
9
+ if totalmem > 100 Mb then restart
10
+ if cpu is greater than 60% for 2 cycles then alert
11
+ if cpu > 80% for 5 cycles then restart
12
+ if loadavg(5min) greater than 10 for 8 cycles then restart
13
+ if 3 restarts within 5 cycles then timeout
14
+
15
+ <% end %>