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,80 @@
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/thin"
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['socket'] ? i : (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
+ w.start = "thin start -C #{file} -o #{number}"
34
+ w.start_grace = 10.seconds
35
+
36
+ w.stop = "thin stop -C #{file} -o #{number}"
37
+ w.stop_grace = 10.seconds
38
+
39
+ w.restart = "thin restart -C #{file} -o #{number}"
40
+
41
+ pid_path = config["chdir"] + "/" + config["pid"]
42
+ ext = File.extname(pid_path)
43
+
44
+ w.pid_file = pid_path.gsub(/#{ext}$/, ".#{number}#{ext}")
45
+
46
+ w.behavior(:clean_pid_file)
47
+
48
+ w.start_if do |start|
49
+ start.condition(:process_running) do |c|
50
+ c.interval = 5.seconds
51
+ c.running = false
52
+ end
53
+ end
54
+
55
+ w.restart_if do |restart|
56
+ restart.condition(:memory_usage) do |c|
57
+ c.above = 150.megabytes
58
+ c.times = [3,5] # 3 out of 5 intervals
59
+ end
60
+
61
+ restart.condition(:cpu_usage) do |c|
62
+ c.above = 50.percent
63
+ c.times = 5
64
+ end
65
+ end
66
+
67
+ w.lifecycle do |on|
68
+ on.condition(:flapping) do |c|
69
+ c.to_state = [:start, :restart]
70
+ c.times = 5
71
+ c.within = 5.minutes
72
+ c.transition = :unmonitored
73
+ c.retry_in = 10.minutes
74
+ c.retry_times = 5
75
+ c.retry_within = 2.hours
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,2 @@
1
+ auth 1
2
+ 1 sha1 <%= heartbeat_auth_key %>
@@ -0,0 +1,15 @@
1
+ # http://linux-ha.org/ha.cf
2
+ logfacility daemon
3
+ keepalive 1
4
+ deadtime 10
5
+ warntime 5
6
+ initdead 120 # depend on your hardware
7
+ udpport 694
8
+ ping <%= heartbeat_ping %>
9
+ bcast <%= heartbeat_bcast %>
10
+ auto_failback <%= heartbeat_auto_failback %>
11
+ <% heartbeat_nodes.each do |node| -%>
12
+ node <%= node %>
13
+ <% end -%>
14
+ respawn hacluster /usr/lib/heartbeat/ipfail
15
+ use_logd yes
@@ -0,0 +1 @@
1
+ <%= heartbeat_preferred_node %> <%= heartbeat_resources %>
@@ -0,0 +1,41 @@
1
+ *filter
2
+
3
+
4
+ # Allows all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
5
+ -A INPUT -i lo -j ACCEPT
6
+ -A INPUT -i ! lo -d 127.0.0.0/8 -j REJECT
7
+
8
+
9
+ # Accepts all established inbound connections
10
+ -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
11
+
12
+
13
+ # Allows all outbound traffic
14
+ # You can modify this to only allow certain traffic
15
+ -A OUTPUT -j ACCEPT
16
+
17
+
18
+ # Allows HTTP and HTTPS connections from anywhere (the normal ports for websites)
19
+ -A INPUT -p tcp --dport 80 -j ACCEPT
20
+ -A INPUT -p tcp --dport 443 -j ACCEPT
21
+ <% port_list.each do |port| %>
22
+ -A INPUT -p tcp --dport <%= port %> -j ACCEPT
23
+ <% end %>
24
+
25
+ # Allows SSH connections on the unrecommended default port
26
+ -A INPUT -p tcp -m state --state NEW --dport <%= ssh_port %> -j ACCEPT
27
+
28
+
29
+ # Allow ping
30
+ -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT
31
+
32
+
33
+ # log iptables denied calls
34
+ -A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7
35
+
36
+
37
+ # Reject all other inbound - default deny unless explicitly allowed policy
38
+ -A INPUT -j REJECT
39
+ -A FORWARD -j REJECT
40
+
41
+ COMMIT
@@ -0,0 +1,32 @@
1
+ # see "man logrotate" for details
2
+ # rotate log files weekly
3
+ weekly
4
+
5
+ # keep 4 weeks worth of backlogs
6
+ rotate 4
7
+
8
+ # create new (empty) log files after rotating old ones
9
+ create
10
+
11
+ # uncomment this if you want your log files compressed
12
+ #compress
13
+
14
+ # packages drop log rotation information into this directory
15
+ include /etc/logrotate.d
16
+
17
+ # no packages own wtmp, or btmp -- we'll rotate them here
18
+ /var/log/wtmp {
19
+ missingok
20
+ monthly
21
+ create 0664 root utmp
22
+ rotate 1
23
+ }
24
+
25
+ /var/log/btmp {
26
+ missingok
27
+ monthly
28
+ create 0664 root utmp
29
+ rotate 1
30
+ }
31
+
32
+ # system-specific logs may be configured here
@@ -0,0 +1,65 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: memcached
4
+ # Should-Start: $local_fs
5
+ # Should-Stop: $local_fs
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: memcached - Memory caching daemon
9
+ # Description: memcached - Memory caching daemon
10
+ ### END INIT INFO
11
+
12
+
13
+ PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
14
+ DAEMON=/usr/local/bin/memcached
15
+ DAEMONBOOTSTRAP=/etc/memcached/memcached.conf
16
+ NAME=memcached
17
+ DESC=memcached
18
+ PIDFILE=<%= memcached_pid_file %>
19
+
20
+ test -x $DAEMON || exit 0
21
+ test -x $DAEMONBOOTSTRAP || exit 0
22
+
23
+ #PIDFILE=`sed -n 's/-P \(\/\)/\1/p' $DAEMONBOOTSTRAP`
24
+ # Remove comments, then tidy whitespace, then concatenate the lines into one line
25
+ ARGS=`sed 's/\#.*//;/^[ \n]*$/d;' $DAEMONBOOTSTRAP | tr '\012' ' '`
26
+
27
+ set -e
28
+
29
+ case "$1" in
30
+ start)
31
+ echo -n "Starting $DESC: "
32
+ touch <%= memcached_pid_file %> && chown <%= memcached_user %>:<%= memcached_group %> <%= memcached_pid_file %>
33
+ start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- $ARGS
34
+ echo "$NAME."
35
+ ;;
36
+ stop)
37
+ echo -n "Stopping $DESC: "
38
+ start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE --exec $DAEMON
39
+ echo "$NAME."
40
+ rm -f $PIDFILE
41
+ ;;
42
+ stop)
43
+ echo -n "Reloading $DESC"
44
+ kill -HUP `cat $PIDFILE`
45
+ echo "$NAME."
46
+ rm -f $PIDFILE
47
+ ;;
48
+
49
+ restart|force-reload)
50
+ echo -n "Restarting $DESC: "
51
+ start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
52
+ rm -f $PIDFILE
53
+ touch <%= memcached_pid_file %> && chown <%= memcached_user %>:<%= memcached_group %> <%= memcached_pid_file %>
54
+
55
+ start-stop-daemon --start --quiet --exec $ARGS
56
+ echo "$NAME."
57
+ ;;
58
+ *)
59
+ N=/etc/init.d/$NAME
60
+ echo "Usage: $N {start|stop|reload|restart|force-reload}" >&2
61
+ exit 1
62
+ ;;
63
+ esac
64
+
65
+ exit 0
@@ -0,0 +1,46 @@
1
+ # 2003 - Jay Bonci <jaybonci@debian.org>
2
+ # This configuration file is read by the start-memcached script provided as
3
+ # part of the Debian GNU/Linux distribution.
4
+
5
+ # Run memcached as a daemon. This command is implied, and is not needed for the
6
+ # daemon to run. See the README.Debian that comes with this package for more
7
+ # information.
8
+ -d
9
+
10
+ #PID File
11
+ -P <%= memcached_pid_file %>
12
+
13
+ # Be verbose
14
+ # -v
15
+
16
+ # Be even more verbose (print client commands as well)
17
+ # -vv
18
+
19
+ # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
20
+ # Note that the daemon will grow to this size, but does not start out holding this much
21
+ # memory
22
+ -m <%= memcached_cache_size %>
23
+
24
+ # Default connection port is 11211
25
+ -p <%= memcached_port %>
26
+
27
+ # Run the daemon as root. The start-memcached will default to running as root if no
28
+ # -u command is present in this config file
29
+ -u <%= memcached_user %>
30
+
31
+ # Specify which IP address to listen on. The default is to listen on all IP addresses
32
+ # This parameter is one of the only security measures that memcached has, so make sure
33
+ # it's listening on a firewalled interface.
34
+ -l <%= memcached_address %>
35
+
36
+ # Limit the number of simultaneous incoming connections. The daemon default is 1024
37
+ # -c 1024
38
+
39
+ # Lock down all paged memory. Consult with the README and homepage before you do this
40
+ # -k
41
+
42
+ # Return error when memory is exhausted (rather than removing items)
43
+ # -M
44
+
45
+ # Maximize core file limit
46
+ # -r
@@ -0,0 +1,11 @@
1
+ /var/www/apps/<%= application %>/shared/log/production.log /var/www/apps/<%= application %>/shared/log/mongrel.*.log {
2
+ daily
3
+ rotate 14
4
+ dateext
5
+ missingok
6
+ compress
7
+ sharedscripts
8
+ copytruncate
9
+ }
10
+
11
+
@@ -0,0 +1,54 @@
1
+ #!/bin/bash
2
+ #
3
+ # Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
4
+ #
5
+ # mongrel_cluster Startup script for Mongrel clusters.
6
+ #
7
+ # chkconfig: - 85 15
8
+ # description: mongrel_cluster manages multiple Mongrel processes for use \
9
+ # behind a load balancer.
10
+ #
11
+
12
+ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local:/usr/local/sbin:/usr/local/bin
13
+ CONF_DIR=/etc/mongrel_cluster
14
+ PID_DIR=/var/run/mongrel_cluster
15
+ # USER=mongrel
16
+
17
+ EVENT=1
18
+
19
+ RETVAL=0
20
+
21
+ # Gracefully exit if the controller is missing.
22
+ which mongrel_cluster_ctl >/dev/null || exit 0
23
+
24
+ # Go no further if config directory is missing.
25
+ [ -d "$CONF_DIR" ] || exit 0
26
+
27
+ case "$1" in
28
+ start)
29
+ # Create pid directory
30
+ mkdir -p $PID_DIR
31
+ # chown $USER:$USER $PID_DIR
32
+
33
+ mongrel_cluster_ctl start --clean -c $CONF_DIR
34
+ RETVAL=$?
35
+ ;;
36
+ stop)
37
+ mongrel_cluster_ctl stop -c $CONF_DIR
38
+ RETVAL=$?
39
+ ;;
40
+ restart)
41
+ mongrel_cluster_ctl restart --clean -c $CONF_DIR
42
+ RETVAL=$?
43
+ ;;
44
+ status)
45
+ mongrel_cluster_ctl status -c $CONF_DIR
46
+ RETVAL=$?
47
+ ;;
48
+ *)
49
+ echo "Usage: mongrel_cluster {start|stop|restart|status}"
50
+ exit 1
51
+ ;;
52
+ esac
53
+
54
+ exit $RETVAL
@@ -0,0 +1,14 @@
1
+ /var/log/mongrel/<%= application %>/*.log {
2
+ daily
3
+ missingok
4
+ rotate 28
5
+ compress
6
+ notifempty
7
+ sharedscripts
8
+ extension gz
9
+ postrotate
10
+ for i in `ls /data/<%= @username %>/shared/log/*.pid`; do
11
+ kill -USR2 `cat $i`
12
+ done
13
+ endscript
14
+ }
@@ -0,0 +1,10 @@
1
+ ---
2
+ user: <%= mongrel_user %>
3
+ group: <%= mongrel_group %>
4
+ cwd: <%= current_path %>
5
+ log_file: <%= mongrel_log_dir %>/mongrel.log
6
+ port: "<%= mongrel_port.to_s %>"
7
+ environment: <%= mongrel_environment %>
8
+ address: <%= mongrel_address %>
9
+ pid_file: <%= mongrel_pid_dir %>/mongrel.pid
10
+ servers: <%= mongrel_servers.to_s %>
@@ -0,0 +1,17 @@
1
+ <% mongrel_servers.times do |counter| -%>
2
+ check process mongrel-<%=mongrel_port+counter%> with pidfile <%= mongrel_pid_dir %>/mongrel.<%=mongrel_port+counter%>.pid
3
+ group mongrel_<%= application %>
4
+ start program = "/usr/local/bin/ruby /usr/local/bin/mongrel_rails cluster::start --clean -C <%= mongrel_conf %> --only <%=mongrel_port+counter%>"
5
+ stop program = "/usr/local/bin/ruby /usr/local/bin/mongrel_rails cluster::stop -C <%= mongrel_conf %> --only <%=mongrel_port+counter%>"
6
+
7
+ if failed host 127.0.0.1 port <%=mongrel_port+counter%> protocol http
8
+ with timeout 10 seconds
9
+ then alert
10
+
11
+ if totalmem > 100 Mb then restart
12
+ if cpu > 60% for 2 cycles then alert
13
+ if cpu > 80% for 5 cycles then restart
14
+ if loadavg(5min) > 10 for 8 cycles then restart
15
+ if 3 restarts within 5 cycles then timeout
16
+
17
+ <% end -%>
@@ -0,0 +1,104 @@
1
+ #!/bin/sh
2
+ # /etc/init.d/monit start and stop monit daemon monitor process.
3
+ # Fredrik Steen, stone@debian.org
4
+ :
5
+ PATH=/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
6
+ DAEMON=/usr/local/bin/monit
7
+ CONFIG="/etc/monitrc"
8
+ NAME=monit
9
+ DESC="daemon monitor"
10
+
11
+ set -e
12
+
13
+ # Check if DAEMON binary exist
14
+ test -f $DAEMON || exit 0
15
+
16
+ ARGS="-c $CONFIG"
17
+
18
+ monit_not_configured () {
19
+ echo -e "monit won't be started/stopped\n\tunless it it's configured"
20
+ if [ "$1" != "stop" ]
21
+ then
22
+ echo -e "\tplease configure monit and then edit /etc/default/monit"
23
+ echo -e "\tand set the \"startup\" variable to 1 in order to allow "
24
+ echo -e "\tmonit to start"
25
+ fi
26
+ exit 0
27
+ }
28
+
29
+ monit_check_config () {
30
+ # Check for emtpy config, probably default configfile.
31
+ if [ "`grep -s -v \"^#\" $CONFIG`" = "" ]; then
32
+ echo "empty config, please edit $CONFIG."
33
+ exit 0
34
+ fi
35
+ }
36
+
37
+ monit_check_perms () {
38
+ # Check the permission on configfile.
39
+ # The permission must not have more than -rwx------ (0700) permissions.
40
+
41
+ # Skip checking, fix perms instead.
42
+ /bin/chmod go-rwx $CONFIG
43
+
44
+ }
45
+
46
+ monit_delayed_monitoring () {
47
+ if [ -x $DELAY ]; then
48
+ $DELAY &
49
+ elif [ -f $DELAY ]; then
50
+ echo
51
+ echo "[WARNING] A delayed start file exists ($DELAY) but it is not executable."
52
+ fi
53
+ }
54
+
55
+ monit_check_syntax () {
56
+ $DAEMON -t;
57
+ # if [ $? ] ; then
58
+ # echo "syntax good"
59
+ # else
60
+ # echo "syntax bad"
61
+ # fi
62
+ }
63
+
64
+
65
+ monit_checks () {
66
+ # Check for emtpy configfile
67
+ monit_check_config
68
+ # Check permissions of configfile
69
+ monit_check_perms
70
+ }
71
+
72
+ case "$1" in
73
+ start)
74
+ echo -n "Starting $DESC: "
75
+ monit_checks $1
76
+ echo -n "$NAME"
77
+ start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
78
+ --exec $DAEMON > /dev/null 2>&1 -- $ARGS
79
+ monit_delayed_monitoring
80
+ echo "."
81
+ ;;
82
+ stop)
83
+ echo -n "Stopping $DESC: "
84
+ #monit_checks $1
85
+ echo -n "$NAME"
86
+ start-stop-daemon --retry 5 --oknodo --stop --quiet --pidfile /var/run/$NAME.pid \
87
+ --exec $DAEMON > /dev/null 2>&1
88
+ echo "."
89
+ ;;
90
+ restart|force-reload)
91
+ $0 stop
92
+ $0 start
93
+ ;;
94
+ syntax)
95
+ monit_check_syntax
96
+ ;;
97
+ *)
98
+ N=/etc/init.d/$NAME
99
+ echo "Usage: $N {start|stop|restart|force-reload|syntax}" >&2
100
+ exit 1
101
+ ;;
102
+ esac
103
+
104
+ exit 0