Empact-deprec 1.99.21

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 (148) hide show
  1. data/CHANGELOG +170 -0
  2. data/COPYING +19 -0
  3. data/LICENSE +339 -0
  4. data/README +136 -0
  5. data/THANKS +5 -0
  6. data/bin/depify +133 -0
  7. data/docs/ANNOUNCE.deprec2 +47 -0
  8. data/docs/README.install +88 -0
  9. data/docs/README.nagios +28 -0
  10. data/docs/README.rails +20 -0
  11. data/docs/README.svn +31 -0
  12. data/docs/ROADMAP.txt +74 -0
  13. data/docs/deprec-1.x/deprec-1.x.quickstart +50 -0
  14. data/docs/deprec-1.x/notes.txt +12 -0
  15. data/docs/deprec_banner.gif +0 -0
  16. data/lib/deprec.rb +8 -0
  17. data/lib/deprec/capistrano_extensions.rb +378 -0
  18. data/lib/deprec/recipes.rb +40 -0
  19. data/lib/deprec/recipes/aoe.rb +117 -0
  20. data/lib/deprec/recipes/apache.rb +179 -0
  21. data/lib/deprec/recipes/ar_sendmail.rb +65 -0
  22. data/lib/deprec/recipes/canonical.rb +57 -0
  23. data/lib/deprec/recipes/deprec.rb +155 -0
  24. data/lib/deprec/recipes/deprecated.rb +71 -0
  25. data/lib/deprec/recipes/example.rb +115 -0
  26. data/lib/deprec/recipes/git.rb +168 -0
  27. data/lib/deprec/recipes/gitosis.rb +47 -0
  28. data/lib/deprec/recipes/god.rb +107 -0
  29. data/lib/deprec/recipes/heartbeat.rb +138 -0
  30. data/lib/deprec/recipes/iptables.rb +53 -0
  31. data/lib/deprec/recipes/logrotate.rb +51 -0
  32. data/lib/deprec/recipes/lvm.rb +20 -0
  33. data/lib/deprec/recipes/memcached.rb +102 -0
  34. data/lib/deprec/recipes/mongrel.rb +209 -0
  35. data/lib/deprec/recipes/monit.rb +130 -0
  36. data/lib/deprec/recipes/mysql.rb +115 -0
  37. data/lib/deprec/recipes/nagios.rb +302 -0
  38. data/lib/deprec/recipes/network.rb +84 -0
  39. data/lib/deprec/recipes/nginx.rb +154 -0
  40. data/lib/deprec/recipes/ntp.rb +96 -0
  41. data/lib/deprec/recipes/php.rb +99 -0
  42. data/lib/deprec/recipes/postfix.rb +105 -0
  43. data/lib/deprec/recipes/rails.rb +302 -0
  44. data/lib/deprec/recipes/ruby.rb +66 -0
  45. data/lib/deprec/recipes/sphinx.rb +83 -0
  46. data/lib/deprec/recipes/ssh.rb +93 -0
  47. data/lib/deprec/recipes/svn.rb +169 -0
  48. data/lib/deprec/recipes/swiftiply.rb +108 -0
  49. data/lib/deprec/recipes/thin.rb +201 -0
  50. data/lib/deprec/recipes/trac.rb +277 -0
  51. data/lib/deprec/recipes/ubuntu.rb +20 -0
  52. data/lib/deprec/recipes/users.rb +90 -0
  53. data/lib/deprec/recipes/utils.rb +39 -0
  54. data/lib/deprec/recipes/xen.rb +259 -0
  55. data/lib/deprec/templates/aoe/aoe-init +55 -0
  56. data/lib/deprec/templates/aoe/fence_aoemask +351 -0
  57. data/lib/deprec/templates/apache/httpd-vhost-app.conf.erb +144 -0
  58. data/lib/deprec/templates/apache/httpd.conf +465 -0
  59. data/lib/deprec/templates/apache/index.html.erb +37 -0
  60. data/lib/deprec/templates/apache/master.css +72 -0
  61. data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
  62. data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
  63. data/lib/deprec/templates/coraid/aoe-init +55 -0
  64. data/lib/deprec/templates/deprec/caprc.erb +14 -0
  65. data/lib/deprec/templates/god/god-init-script +71 -0
  66. data/lib/deprec/templates/god/god-notifications +0 -0
  67. data/lib/deprec/templates/god/god_mongrel.erb +81 -0
  68. data/lib/deprec/templates/god/god_mysql.erb +50 -0
  69. data/lib/deprec/templates/god/god_nginx.erb +61 -0
  70. data/lib/deprec/templates/god/god_thin.erb +80 -0
  71. data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
  72. data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
  73. data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
  74. data/lib/deprec/templates/iptables/iptables.up.erb +41 -0
  75. data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
  76. data/lib/deprec/templates/memcached/memcached-init-script +65 -0
  77. data/lib/deprec/templates/memcached/memcached.conf.erb +46 -0
  78. data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
  79. data/lib/deprec/templates/mongrel/mongrel_cluster-init-script +54 -0
  80. data/lib/deprec/templates/mongrel/mongrel_cluster.logrotate.d +14 -0
  81. data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
  82. data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
  83. data/lib/deprec/templates/monit/monit-init-script +104 -0
  84. data/lib/deprec/templates/monit/monitrc.erb +227 -0
  85. data/lib/deprec/templates/monit/nothing +0 -0
  86. data/lib/deprec/templates/mysql/create_databases.sql +20 -0
  87. data/lib/deprec/templates/mysql/database.yml.prod +6 -0
  88. data/lib/deprec/templates/mysql/database.yml.stage +6 -0
  89. data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
  90. data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
  91. data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
  92. data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
  93. data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
  94. data/lib/deprec/templates/nagios/contacts.cfg.erb +75 -0
  95. data/lib/deprec/templates/nagios/hosts.cfg.erb +70 -0
  96. data/lib/deprec/templates/nagios/htpasswd.users +1 -0
  97. data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
  98. data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
  99. data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
  100. data/lib/deprec/templates/nagios/nrpe.cfg.erb +208 -0
  101. data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
  102. data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
  103. data/lib/deprec/templates/nagios/services.cfg.erb +7 -0
  104. data/lib/deprec/templates/nagios/templates.cfg.erb +190 -0
  105. data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
  106. data/lib/deprec/templates/network/hostname.erb +1 -0
  107. data/lib/deprec/templates/network/hosts.erb +2 -0
  108. data/lib/deprec/templates/network/interfaces.erb +18 -0
  109. data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
  110. data/lib/deprec/templates/nginx/mime.types.erb +70 -0
  111. data/lib/deprec/templates/nginx/nginx-init-script +62 -0
  112. data/lib/deprec/templates/nginx/nginx.conf.erb +53 -0
  113. data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
  114. data/lib/deprec/templates/nginx/nothing.conf +1 -0
  115. data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +45 -0
  116. data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
  117. data/lib/deprec/templates/postfix/aliases.erb +3 -0
  118. data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
  119. data/lib/deprec/templates/postfix/main.cf.erb +41 -0
  120. data/lib/deprec/templates/postfix/master.cf.erb +77 -0
  121. data/lib/deprec/templates/rails/database.yml.erb +6 -0
  122. data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
  123. data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
  124. data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
  125. data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
  126. data/lib/deprec/templates/swiftiply/swiftiply-init-script +61 -0
  127. data/lib/deprec/templates/swiftiply/swiftiply.yml.erb +11 -0
  128. data/lib/deprec/templates/thin/thin-init-script +51 -0
  129. data/lib/deprec/templates/thin/thin.yml.erb +11 -0
  130. data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
  131. data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
  132. data/lib/deprec/templates/trac/trac.ini.erb +169 -0
  133. data/lib/deprec/templates/trac/trac_deprec.png +0 -0
  134. data/lib/deprec/templates/trac/tracd-init.erb +43 -0
  135. data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
  136. data/lib/deprec/templates/xen/15-disable-hwclock +40 -0
  137. data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
  138. data/lib/deprec/templates/xen/xen-tools.conf.erb +220 -0
  139. data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
  140. data/lib/deprec/templates/xen/xend-init.erb +69 -0
  141. data/lib/deprec/templates/xen/xendomains.erb +137 -0
  142. data/lib/deprec/templates/xen/xm.tmpl.erb +85 -0
  143. data/lib/vmbuilder_plugins/all.rb +20 -0
  144. data/lib/vmbuilder_plugins/apt.rb +93 -0
  145. data/lib/vmbuilder_plugins/emerge.rb +76 -0
  146. data/lib/vmbuilder_plugins/gem.rb +90 -0
  147. data/lib/vmbuilder_plugins/std.rb +203 -0
  148. metadata +207 -0
@@ -0,0 +1,37 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
+ "http://www.w3.org/TR/html4/strict.dtd">
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
6
+ <title>Apache2 installed by deprec</title>
7
+ <link rel="stylesheet" href="/master.css" type="text/css" media="screen" title="no title" charset="utf-8">
8
+
9
+ </head>
10
+ <body id="" onload="">
11
+ <div id="wrapper">
12
+ <h1>Apache2 installed by deprec</h1>
13
+ <h2>Commands</h2>
14
+ <dl>
15
+ <dt>cap deprec:apache:start</dt><dd>Start apache</dd>
16
+ <dt>cap deprec:apache:stop</dt><dd>Stop apache</dd>
17
+ <dt>cap deprec:apache:restart</dt><dd>Stop restart</dd>
18
+ <dt>cap deprec:apache:reload</dt><dd>Reload apache</dd>
19
+
20
+ <dt>cap deprec:apache:install</dt><dd>Install apache</dd>
21
+ <dt>cap deprec:apache:config_gen</dt><dd>Generate apache configs</dd>
22
+
23
+ <dt>cap deprec:apache:activate</dt><dd>Start Apache when server boots</dd>
24
+ <dt>cap deprec:apache:deactivate</dt><dd>Don't start Apache when server boots</dd>
25
+
26
+ </dl>
27
+
28
+ <dl>
29
+ <p>Installation options</p>
30
+ <% SRC_PACKAGES[:apache].each do |key, val| %>
31
+ <dt><%= key %></dt>
32
+ <dd><%= val %></dd>
33
+ <% end %>
34
+ </dl>
35
+ </div>
36
+ </body>
37
+ </html>
@@ -0,0 +1,72 @@
1
+ /*-----------------------------------------------------------------------------
2
+ Basic Stylesheet
3
+
4
+ version: 1
5
+ author: Mike Bailey
6
+ email: mike@bailey.net.au
7
+ website: http://mike.bailey.net.au/
8
+ -----------------------------------------------------------------------------*/
9
+
10
+ /* General stuff *************************************************************/
11
+
12
+ * {
13
+ padding:0;
14
+ margin: 0;
15
+ font-family: sans-serif;
16
+ }
17
+
18
+ body {
19
+ text-align: center;
20
+ min-width: 760;
21
+ }
22
+
23
+ .clear {
24
+ clear: both;
25
+ }
26
+
27
+ h1 {
28
+ padding: 0.5em;
29
+ }
30
+
31
+ dl {
32
+ border: 1px solid red;
33
+ padding: 1em;
34
+ }
35
+
36
+ dl p {
37
+ font-size: 1.5em;
38
+ padding: .5em 0;
39
+ }
40
+
41
+ dt {
42
+ padding: 0 0 0 1em;
43
+ }
44
+
45
+ dd {
46
+ padding: 0 0 1em 2em;
47
+ color: darkblue;
48
+ }
49
+
50
+
51
+ /* Layout ********************************************************************/
52
+
53
+ #wrapper {
54
+ width: 720px;
55
+ background: #d0d0d0;
56
+ margin: 0 auto;
57
+ text-align: left;
58
+ }
59
+
60
+
61
+ /* Navigation links **********************************************************/
62
+
63
+ ul#navlinks {
64
+ width: 720px;
65
+ list-style: none;
66
+ background: #FAA819;
67
+ float: left;
68
+ }
69
+
70
+ ul li {
71
+ float:left;
72
+ }
@@ -0,0 +1,9 @@
1
+ /var/www/apps/<%= application %>/shared/log/ar_sendmail.log {
2
+ daily
3
+ rotate 14
4
+ dateext
5
+ missingok
6
+ compress
7
+ sharedscripts
8
+ copytruncate
9
+ }
@@ -0,0 +1,5 @@
1
+ check process ar_sendmail-<%= application %> with pidfile <%= current_path %>/tmp/pids/ar_sendmail.pid
2
+ start program = "/usr/local/sbin/daemonize -c <%= current_path %> -o <%= current_path %>/log/ar_sendmail.log -e <%= current_path %>/log/ar_sendmail.log -p <%= current_path %>/tmp/pids/ar_sendmail.pid -l <%= current_path %>/tmp/pids/ar_sendmail.pid /usr/local/bin/ar_sendmail --environment production --verbose"
3
+ stop program = "/usr/bin/xargs kill -9 < <%= current_path %>/tmp/pids/ar_sendmail.pid"
4
+
5
+ if 3 restarts within 5 cycles then timeout
@@ -0,0 +1,55 @@
1
+ #! /bin/sh
2
+ # aoe-init - example init script for ATA over Ethernet storage
3
+ #
4
+ # Edit this script for your purposes. (Changing "eth1" to the
5
+ # appropriate interface name, adding commands, etc.) You might
6
+ # need to tune the sleep times.
7
+ #
8
+ # Install this script in /etc/init.d with the other init scripts.
9
+ #
10
+ # Make it executable:
11
+ # chmod 755 /etc/init.d/aoe-init
12
+ #
13
+ # Install symlinks for boot time:
14
+ # cd /etc/rc3.d && ln -s ../init.d/aoe-init S99aoe-init
15
+ # cd /etc/rc5.d && ln -s ../init.d/aoe-init S99aoe-init
16
+ #
17
+ # Install symlinks for shutdown time:
18
+ # cd /etc/rc0.d && ln -s ../init.d/aoe-init K01aoe-init
19
+ # cd /etc/rc1.d && ln -s ../init.d/aoe-init K01aoe-init
20
+ # cd /etc/rc2.d && ln -s ../init.d/aoe-init K01aoe-init
21
+ # cd /etc/rc6.d && ln -s ../init.d/aoe-init K01aoe-init
22
+ #
23
+
24
+ case "$1" in
25
+ "start")
26
+ # load any needed network drivers here
27
+
28
+ # replace "eth1" with your aoe network interface
29
+ ifconfig eth1 up
30
+
31
+ # time for network interface to come up
32
+ sleep 4
33
+
34
+ modprobe aoe
35
+
36
+ # time for AoE discovery and udev
37
+ sleep 7
38
+
39
+ # add your raid assemble commands here
40
+ # add any LVM commands if needed (e.g. vgchange)
41
+ # add your filesystem mount commands here
42
+
43
+ test -d /var/lock/subsys && touch /var/lock/subsys/aoe-init
44
+ ;;
45
+ "stop")
46
+ # add your filesystem umount commands here
47
+ # deactivate LVM volume groups if needed
48
+ # add your raid stop commands here
49
+ rmmod aoe
50
+ rm -f /var/lock/subsys/aoe-init
51
+ ;;
52
+ *)
53
+ echo "usage: `basename $0` {start|stop}" 1>&2
54
+ ;;
55
+ esac
@@ -0,0 +1,14 @@
1
+ ssh_options[:paranoid] = false
2
+ ssh_options[:forward_agent] = true
3
+
4
+
5
+ # Just import the general purpose tasks
6
+ require '/deprec/general_purpose' if respond_to?(:namespace)
7
+
8
+ # Enable all deprec tasks all the time. This will change the
9
+ # behviour of some standard cap tasks (like 'cap deploy') so
10
+ # only enable it if you know what you're doing!
11
+ #
12
+ # require 'deprec/recipes' unless respond_to?(:namespace)
13
+
14
+
@@ -0,0 +1,71 @@
1
+ #!/bin/bash
2
+
3
+ ### BEGIN INIT INFO
4
+ # Provides: god
5
+ # Default-Start: 2 3 4 5
6
+ # Default-Stop: 0 1 6
7
+ # Short-Description: start and stop god
8
+ # Description: monitoring by god.
9
+ ### END INIT INFO
10
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
11
+ DESC="monitoring daemon"
12
+ NAME=god
13
+ DAEMON=/usr/local/bin/$NAME
14
+ CONFIGFILEDIR=/etc/god
15
+ PIDFILE=/var/run/god/$NAME.pid
16
+ LOGFILE=/var/log/god.log
17
+ SCRIPTNAME=/etc/init.d/$NAME
18
+
19
+ # Check if DAEMON binary exist
20
+ test -f $DAEMON || exit 0
21
+
22
+ ARGS="-l $LOGFILE"
23
+
24
+ RETVAL=0
25
+ set -e
26
+
27
+ d_start() {
28
+ start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
29
+ --exec $DAEMON > /dev/null 2>&1 -- $ARGS
30
+ for file in `ls -1 $CONFIGFILEDIR/*.god`; do $DAEMON load $file; done
31
+ }
32
+
33
+ d_stop() {
34
+ start-stop-daemon --retry 5 --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
35
+ --exec $DAEMON > /dev/null 2>&1
36
+ }
37
+
38
+ d_reload() {
39
+ kill -HUP `cat $PIDFILE` || echo -en "\n can't reload"
40
+ }
41
+
42
+ case "$1" in
43
+ start)
44
+ echo -n "Starting $DESC: $NAME"
45
+ d_start
46
+ echo "."
47
+ ;;
48
+ stop)
49
+ echo -n "Stopping $DESC: $NAME"
50
+ d_stop
51
+ echo "."
52
+ ;;
53
+ reload)
54
+ echo -n "Reloading $DESC configuration..."
55
+ d_reload
56
+ echo "."
57
+ ;;
58
+ restart)
59
+ echo -n "Restarting $DESC: $NAME"
60
+ d_stop
61
+ sleep 5
62
+ d_start
63
+ echo "."
64
+ ;;
65
+ *)
66
+ echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
67
+ exit 3
68
+ ;;
69
+ esac
70
+
71
+ exit 0
@@ -0,0 +1,81 @@
1
+ # == God config file
2
+ # http://god.rubyforge.org/
3
+ # Authors: Gump and michael@glauche.de
4
+ #
5
+ # Config file for god that configures watches for each instance of a thin server for
6
+ # each thin configuration file found in /etc/thin.
7
+ # In order to get it working on Ubuntu, I had to make a change to god as noted at
8
+ # the following blog:
9
+ # http://blog.alexgirard.com/2007/10/25/ruby-one-line-to-save-god/
10
+ #
11
+ require 'yaml'
12
+
13
+ config_path = "/etc/mongrel_cluster"
14
+
15
+ Dir[config_path + "/*.yml"].each do |file|
16
+ config = YAML.load_file(file)
17
+ num_servers = config["servers"] ||= 1
18
+
19
+ (0...num_servers).each do |i|
20
+ # UNIX socket cluster use number 0 to 2 (for 3 servers)
21
+ # and tcp cluster use port number 3000 to 3002.
22
+ number = config['port'] + i
23
+
24
+ God.watch do |w|
25
+ w.group = "thin-" + File.basename(file, ".yml")
26
+ w.name = w.group + "-#{number}"
27
+
28
+ w.interval = 30.seconds
29
+
30
+ w.uid = config["user"]
31
+ w.gid = config["group"]
32
+
33
+
34
+ w.start = "mongrel_rails cluster::start -C #{file}"
35
+ w.start_grace = 10.seconds
36
+
37
+ w.stop = "mongrel_rails cluster::stop -C #{file}"
38
+ w.stop_grace = 10.seconds
39
+
40
+ w.restart = "mongrel_rails cluster::restart -C #{file}"
41
+
42
+ pid_path = config["cwd"] + "/" + config["pidfile"]
43
+ ext = File.extname(pid_path)
44
+
45
+ w.pid_file = pid_path.gsub(/#{ext}$/, ".#{number}#{ext}")
46
+
47
+ w.behavior(:clean_pid_file)
48
+
49
+ w.start_if do |start|
50
+ start.condition(:process_running) do |c|
51
+ c.interval = 5.seconds
52
+ c.running = false
53
+ end
54
+ end
55
+
56
+ w.restart_if do |restart|
57
+ restart.condition(:memory_usage) do |c|
58
+ c.above = 150.megabytes
59
+ c.times = [3,5] # 3 out of 5 intervals
60
+ end
61
+
62
+ restart.condition(:cpu_usage) do |c|
63
+ c.above = 50.percent
64
+ c.times = 5
65
+ end
66
+ end
67
+
68
+ w.lifecycle do |on|
69
+ on.condition(:flapping) do |c|
70
+ c.to_state = [:start, :restart]
71
+ c.times = 5
72
+ c.within = 5.minutes
73
+ c.transition = :unmonitored
74
+ c.retry_in = 10.minutes
75
+ c.retry_times = 5
76
+ c.retry_within = 2.hours
77
+ end
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,50 @@
1
+ God.watch do |w|
2
+ w.name = "mysql"
3
+ w.interval = 30.seconds # default
4
+ w.start = "/etc/init.d/mysql start"
5
+ w.stop = "/etc/init.d/mysql stop"
6
+ w.restart = "/etc/init.d/mysql restart"
7
+ w.start_grace = 20.seconds
8
+ w.restart_grace = 20.seconds
9
+ w.pid_file = "/var/run/mysqld/mysqld.pid"
10
+
11
+ w.behavior(:clean_pid_file)
12
+
13
+ # determine the state on startup
14
+ w.transition(:init, { true => :up, false => :start }) do |on|
15
+ on.condition(:process_running) do |c|
16
+ c.running = true
17
+ end
18
+ end
19
+
20
+ # determine when process has finished starting
21
+ w.transition([:start, :restart], :up) do |on|
22
+ on.condition(:process_running) do |c|
23
+ c.running = true
24
+ end
25
+ # failsafe
26
+ on.condition(:tries) do |c|
27
+ c.times = 8
28
+ c.within = 2.minutes
29
+ c.transition = :start
30
+ end
31
+ end
32
+
33
+ # start if process is not running
34
+ w.transition(:up, :start) do |on|
35
+ on.condition(:process_exits)
36
+ end
37
+
38
+ # lifecycle
39
+ w.lifecycle do |on|
40
+ on.condition(:flapping) do |c|
41
+ c.to_state = [:start, :restart]
42
+ c.times = 5
43
+ c.within = 1.minute
44
+ c.transition = :unmonitored
45
+ c.retry_in = 10.minutes
46
+ c.retry_times = 5
47
+ c.retry_within = 2.hours
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,61 @@
1
+ God.watch do |w|
2
+ w.name = "nginx"
3
+ w.interval = 30.seconds # default
4
+ w.start = "service nginx start"
5
+ w.stop = "service nginx stop"
6
+ w.restart = "service nginx restart"
7
+ w.start_grace = 20.seconds
8
+ w.restart_grace = 20.seconds
9
+ w.pid_file = "/var/run/nginx/nginx.pid"
10
+
11
+ w.behavior(:clean_pid_file)
12
+
13
+ # determine the state on startup
14
+ w.transition(:init, { true => :up, false => :start }) do |on|
15
+ on.condition(:process_running) do |c|
16
+ c.running = true
17
+ end
18
+ end
19
+
20
+ # determine when process has finished starting
21
+ w.transition([:start, :restart], :up) do |on|
22
+ on.condition(:process_running) do |c|
23
+ c.running = true
24
+ end
25
+ # failsafe
26
+ on.condition(:tries) do |c|
27
+ c.times = 8
28
+ c.within = 2.minutes
29
+ c.transition = :start
30
+ end
31
+ end
32
+
33
+ # start if process is not running
34
+ w.transition(:up, :start) do |on|
35
+ on.condition(:process_exits)
36
+ end
37
+
38
+ w.transition(:up, :restart) do |on|
39
+ on.condition(:http_response_code) do |c|
40
+ c.host = 'localhost'
41
+ c.port = 80
42
+ c.path = '/monitor.html'
43
+ c.code_is_not = 200
44
+ c.timeout = 10.seconds
45
+ c.times = [3, 5]
46
+ end
47
+ end
48
+
49
+ # lifecycle
50
+ w.lifecycle do |on|
51
+ on.condition(:flapping) do |c|
52
+ c.to_state = [:start, :restart]
53
+ c.times = 5
54
+ c.within = 1.minute
55
+ c.transition = :unmonitored
56
+ c.retry_in = 10.minutes
57
+ c.retry_times = 5
58
+ c.retry_within = 2.hours
59
+ end
60
+ end
61
+ end