hennk-hennk-ec2onrails 0.9.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (150) hide show
  1. data/CHANGELOG +0 -0
  2. data/COPYING +339 -0
  3. data/Manifest +148 -0
  4. data/README.textile +214 -0
  5. data/Rakefile +36 -0
  6. data/TODO +5 -0
  7. data/ec2onrails.gemspec +44 -0
  8. data/lib/ec2onrails/capistrano_utils.rb +33 -0
  9. data/lib/ec2onrails/recipes.rb +460 -0
  10. data/lib/ec2onrails/version.rb +32 -0
  11. data/lib/ec2onrails.rb +20 -0
  12. data/server/build-ec2onrails.sh +44 -0
  13. data/server/files/etc/aliases +6 -0
  14. data/server/files/etc/aliases.db +0 -0
  15. data/server/files/etc/apache2/apache2.conf +295 -0
  16. data/server/files/etc/apache2/conf.d/app.proxy_cluster.conf +7 -0
  17. data/server/files/etc/apache2/conf.d/app.proxy_frontend.conf +10 -0
  18. data/server/files/etc/apache2/mods-available/proxy.conf +18 -0
  19. data/server/files/etc/apache2/sites-available/app.common +58 -0
  20. data/server/files/etc/apache2/sites-available/app.custom +0 -0
  21. data/server/files/etc/apache2/sites-available/default +17 -0
  22. data/server/files/etc/apache2/sites-available/default-ssl +18 -0
  23. data/server/files/etc/cron.d/backup_app_db_to_s3 +6 -0
  24. data/server/files/etc/cron.daily/app +5 -0
  25. data/server/files/etc/cron.daily/logrotate_post +27 -0
  26. data/server/files/etc/cron.hourly/app +5 -0
  27. data/server/files/etc/cron.monthly/app +5 -0
  28. data/server/files/etc/cron.weekly/app +5 -0
  29. data/server/files/etc/denyhosts.conf +628 -0
  30. data/server/files/etc/dpkg/dpkg.cfg +13 -0
  31. data/server/files/etc/ec2onrails/balancer_members +6 -0
  32. data/server/files/etc/ec2onrails/roles.yml +5 -0
  33. data/server/files/etc/environment +2 -0
  34. data/server/files/etc/event.d/monit +13 -0
  35. data/server/files/etc/init.d/ec2-every-startup +29 -0
  36. data/server/files/etc/init.d/ec2-first-startup +36 -0
  37. data/server/files/etc/init.d/mongrel +91 -0
  38. data/server/files/etc/init.d/set_roles +3 -0
  39. data/server/files/etc/logrotate.d/apache2 +13 -0
  40. data/server/files/etc/logrotate.d/mysql-server +23 -0
  41. data/server/files/etc/logrotate.d/rails +7 -0
  42. data/server/files/etc/memcached.conf +47 -0
  43. data/server/files/etc/mongrel_cluster/app.yml +9 -0
  44. data/server/files/etc/monit/app.monitrc +71 -0
  45. data/server/files/etc/monit/db_primary.monitrc +10 -0
  46. data/server/files/etc/monit/memcache.monitrc +8 -0
  47. data/server/files/etc/monit/monitrc +13 -0
  48. data/server/files/etc/monit/system.monitrc +15 -0
  49. data/server/files/etc/monit/web.monitrc +10 -0
  50. data/server/files/etc/motd.tail +13 -0
  51. data/server/files/etc/mysql/my.cnf +149 -0
  52. data/server/files/etc/postfix/main.cf +4 -0
  53. data/server/files/etc/rc0.d/K10mongrel +91 -0
  54. data/server/files/etc/rc1.d/K10mongrel +91 -0
  55. data/server/files/etc/rc2.d/S90mongrel +91 -0
  56. data/server/files/etc/rc3.d/S90mongrel +91 -0
  57. data/server/files/etc/rc4.d/S90mongrel +91 -0
  58. data/server/files/etc/rc5.d/S90mongrel +91 -0
  59. data/server/files/etc/rc6.d/K10mongrel +91 -0
  60. data/server/files/etc/rcS.d/S91ec2-first-startup +36 -0
  61. data/server/files/etc/rcS.d/S92ec2-every-startup +29 -0
  62. data/server/files/etc/rcS.d/S99set_roles +3 -0
  63. data/server/files/etc/ssh/sshd_config +94 -0
  64. data/server/files/etc/sudoers +24 -0
  65. data/server/files/etc/syslog.conf +69 -0
  66. data/server/files/usr/local/ec2onrails/COPYING +339 -0
  67. data/server/files/usr/local/ec2onrails/bin/archive_file.rb +44 -0
  68. data/server/files/usr/local/ec2onrails/bin/backup_app_db.rb +83 -0
  69. data/server/files/usr/local/ec2onrails/bin/backup_files.rb +51 -0
  70. data/server/files/usr/local/ec2onrails/bin/mongrel_start +8 -0
  71. data/server/files/usr/local/ec2onrails/bin/mongrel_stop +8 -0
  72. data/server/files/usr/local/ec2onrails/bin/rails_env +35 -0
  73. data/server/files/usr/local/ec2onrails/bin/rebundle.sh +70 -0
  74. data/server/files/usr/local/ec2onrails/bin/restore_app_db.rb +58 -0
  75. data/server/files/usr/local/ec2onrails/bin/restore_files.rb +59 -0
  76. data/server/files/usr/local/ec2onrails/bin/set_rails_env +40 -0
  77. data/server/files/usr/local/ec2onrails/bin/set_roles.rb +156 -0
  78. data/server/files/usr/local/ec2onrails/config +30 -0
  79. data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +101 -0
  80. data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +126 -0
  81. data/server/files/usr/local/ec2onrails/lib/utils.rb +16 -0
  82. data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/get-hostname.sh +25 -0
  83. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs.sh +39 -0
  84. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key.sh +49 -0
  85. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc.sh +30 -0
  86. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh +24 -0
  87. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup_credentials.sh +33 -0
  88. data/server/rakefile.rb +245 -0
  89. data/setup.rb +1585 -0
  90. data/test/autobench.conf +60 -0
  91. data/test/spec/lib/s3_helper_spec.rb +134 -0
  92. data/test/spec/lib/s3_old.yml +3 -0
  93. data/test/spec/test_files/test1 +0 -0
  94. data/test/spec/test_files/test2 +0 -0
  95. data/test/test_app/Capfile +3 -0
  96. data/test/test_app/README +182 -0
  97. data/test/test_app/Rakefile +10 -0
  98. data/test/test_app/app/controllers/application.rb +7 -0
  99. data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
  100. data/test/test_app/app/controllers/fast_controller.rb +5 -0
  101. data/test/test_app/app/controllers/slow_controller.rb +6 -0
  102. data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
  103. data/test/test_app/app/helpers/application_helper.rb +3 -0
  104. data/test/test_app/app/helpers/db_fast_helper.rb +2 -0
  105. data/test/test_app/app/helpers/fast_helper.rb +2 -0
  106. data/test/test_app/app/helpers/slow_helper.rb +2 -0
  107. data/test/test_app/app/helpers/very_slow_helper.rb +2 -0
  108. data/test/test_app/config/boot.rb +109 -0
  109. data/test/test_app/config/database.yml +36 -0
  110. data/test/test_app/config/deploy.rb +21 -0
  111. data/test/test_app/config/environment.rb +60 -0
  112. data/test/test_app/config/environments/development.rb +21 -0
  113. data/test/test_app/config/environments/production.rb +18 -0
  114. data/test/test_app/config/environments/test.rb +19 -0
  115. data/test/test_app/config/routes.rb +27 -0
  116. data/test/test_app/db/schema.rb +7 -0
  117. data/test/test_app/doc/README_FOR_APP +2 -0
  118. data/test/test_app/public/404.html +30 -0
  119. data/test/test_app/public/500.html +30 -0
  120. data/test/test_app/public/dispatch.cgi +10 -0
  121. data/test/test_app/public/dispatch.fcgi +24 -0
  122. data/test/test_app/public/dispatch.rb +10 -0
  123. data/test/test_app/public/favicon.ico +0 -0
  124. data/test/test_app/public/images/rails.png +0 -0
  125. data/test/test_app/public/javascripts/application.js +2 -0
  126. data/test/test_app/public/javascripts/controls.js +963 -0
  127. data/test/test_app/public/javascripts/dragdrop.js +972 -0
  128. data/test/test_app/public/javascripts/effects.js +1120 -0
  129. data/test/test_app/public/javascripts/prototype.js +4225 -0
  130. data/test/test_app/public/robots.txt +1 -0
  131. data/test/test_app/script/about +3 -0
  132. data/test/test_app/script/breakpointer +3 -0
  133. data/test/test_app/script/console +3 -0
  134. data/test/test_app/script/destroy +3 -0
  135. data/test/test_app/script/generate +3 -0
  136. data/test/test_app/script/performance/benchmarker +3 -0
  137. data/test/test_app/script/performance/profiler +3 -0
  138. data/test/test_app/script/performance/request +3 -0
  139. data/test/test_app/script/plugin +3 -0
  140. data/test/test_app/script/process/inspector +3 -0
  141. data/test/test_app/script/process/reaper +3 -0
  142. data/test/test_app/script/process/spawner +3 -0
  143. data/test/test_app/script/runner +3 -0
  144. data/test/test_app/script/server +3 -0
  145. data/test/test_app/test/functional/db_fast_controller_test.rb +18 -0
  146. data/test/test_app/test/functional/fast_controller_test.rb +18 -0
  147. data/test/test_app/test/functional/slow_controller_test.rb +18 -0
  148. data/test/test_app/test/functional/very_slow_controller_test.rb +18 -0
  149. data/test/test_app/test/test_helper.rb +28 -0
  150. metadata +263 -0
@@ -0,0 +1,36 @@
1
+ #!/bin/sh
2
+
3
+ # This file is part of EC2 on Rails.
4
+ # http://rubyforge.org/projects/ec2onrails/
5
+ #
6
+ # Copyright 2007 Paul Dowman, http://pauldowman.com/
7
+ #
8
+ # EC2 on Rails is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # EC2 on Rails is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+
22
+ # This script runs the ec2 startup scripts
23
+
24
+ FILE=/ec2onrails-first-boot
25
+
26
+ if [ -e $FILE ] ; then
27
+
28
+ # this is an ugly hack to make sure DHCP initialization is finished:
29
+ sleep 15
30
+
31
+ for SCRIPT in `ls -I README /usr/local/ec2onrails/startup-scripts/first-startup` ; do
32
+ "/usr/local/ec2onrails/startup-scripts/first-startup/$SCRIPT"
33
+ done
34
+
35
+ rm $FILE
36
+ fi
@@ -0,0 +1,91 @@
1
+ #!/bin/sh -e
2
+
3
+ # This file is part of EC2 on Rails.
4
+ # http://rubyforge.org/projects/ec2onrails/
5
+ #
6
+ # Copyright 2007 Paul Dowman, http://pauldowman.com/
7
+ #
8
+ # EC2 on Rails is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # EC2 on Rails is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+
22
+ #
23
+ # This is the init script to start/stop mongrel
24
+ #
25
+
26
+ NAME="mongrel cluster"
27
+ NO_START=0
28
+
29
+ ########################################
30
+
31
+ if [ ! -d /mnt/app/current ] ; then
32
+ echo "/mnt/app/current doesn't exist, not starting mongrel..."
33
+ exit 0
34
+ fi
35
+
36
+ start_cmd() {
37
+ /usr/local/ec2onrails/bin/mongrel_start
38
+ return $?
39
+ }
40
+
41
+ stop_cmd() {
42
+ /usr/local/ec2onrails/bin/mongrel_stop
43
+ return $?
44
+ }
45
+
46
+ restart_cmd() {
47
+ /usr/local/ec2onrails/bin/mongrel_stop && /usr/local/ec2onrails/bin/mongrel_start
48
+ return $?
49
+ }
50
+
51
+
52
+ ########################################
53
+
54
+ . /lib/lsb/init-functions
55
+
56
+ test -f /etc/default/rcS && . /etc/default/rcS
57
+
58
+ if [ "$NO_START" != "0" -a "$1" != "stop" ]; then
59
+ [ "$VERBOSE" != no ] && log_warning_msg "Not starting $NAME - edit $0 and change NO_START to be 0.";
60
+ exit 0;
61
+ fi
62
+
63
+ case "$1" in
64
+ start)
65
+ log_begin_msg "Starting $NAME..."
66
+ if start_cmd; then
67
+ log_end_msg 0
68
+ else
69
+ log_end_msg 1
70
+ fi
71
+ ;;
72
+ stop)
73
+ log_begin_msg "Stopping $NAME..."
74
+ if stop_cmd; then
75
+ log_end_msg 0
76
+ else
77
+ log_end_msg 1
78
+ fi
79
+ ;;
80
+ restart)
81
+ log_begin_msg "Restarting $NAME..."
82
+ if restart_cmd; then
83
+ log_end_msg 0
84
+ else
85
+ log_end_msg 1
86
+ fi
87
+ ;;
88
+ *)
89
+ log_success_msg "Usage: $0 {start|stop|restart}"
90
+ ;;
91
+ esac
@@ -0,0 +1,3 @@
1
+ #!/bin/sh
2
+
3
+ /usr/local/ec2onrails/bin/set_roles.rb
@@ -0,0 +1,13 @@
1
+ /mnt/log/apache2/*.log {
2
+ daily
3
+ missingok
4
+ dateext
5
+ create 640 root adm
6
+ sharedscripts
7
+ copytruncate
8
+ postrotate
9
+ if [ -f /var/run/apache2.pid ]; then
10
+ /etc/init.d/apache2 reload > /dev/null
11
+ fi
12
+ endscript
13
+ }
@@ -0,0 +1,23 @@
1
+ /mnt/log/mysql.log /mnt/log/mysql/mysql.log /mnt/log/mysql/mysql-slow.log {
2
+ daily
3
+ missingok
4
+ dateext
5
+ create 640 mysql adm
6
+ sharedscripts
7
+ postrotate
8
+ test -x /usr/bin/mysqladmin || exit 0
9
+
10
+ # If this fails, check debian.conf!
11
+ export HOME=/etc/mysql/my.cnf
12
+ MYADMIN="/usr/bin/mysqladmin --defaults-file=/etc/mysql/debian.cnf"
13
+ if [ -z "`$MYADMIN ping 2>/dev/null`" ]; then
14
+ # Really no mysqld or rather a missing debian-sys-maint user?
15
+ # If this occurs and is not a error please report a bug.
16
+ if ps cax | grep -q mysqld; then
17
+ exit 1
18
+ fi
19
+ else
20
+ $MYADMIN flush-logs
21
+ fi
22
+ endscript
23
+ }
@@ -0,0 +1,7 @@
1
+ # Rotate Rails application logs
2
+ /mnt/app/current/log/*.log {
3
+ daily
4
+ missingok
5
+ dateext
6
+ copytruncate
7
+ }
@@ -0,0 +1,47 @@
1
+ # memcached default config file
2
+ # 2003 - Jay Bonci <jaybonci@debian.org>
3
+ # This configuration file is read by the start-memcached script provided as
4
+ # part of the Debian GNU/Linux distribution.
5
+
6
+ # Run memcached as a daemon. This command is implied, and is not needed for the
7
+ # daemon to run. See the README.Debian that comes with this package for more
8
+ # information.
9
+ -d
10
+
11
+ # Log memcached's output to /var/log/memcached
12
+ logfile /mnt/log/memcached.log
13
+
14
+ # Be verbose
15
+ # -v
16
+
17
+ # Be even more verbose (print client commands as well)
18
+ # -vv
19
+
20
+ # Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
21
+ # Note that the daemon will grow to this size, but does not start out holding this much
22
+ # memory
23
+ -m 128
24
+
25
+ # Default connection port is 11211
26
+ -p 11211
27
+
28
+ # Run the daemon as root. The start-memcached will default to running as root if no
29
+ # -u command is present in this config file
30
+ -u nobody
31
+
32
+ # Specify which IP address to listen on. The default is to listen on all IP addresses
33
+ # This parameter is one of the only security measures that memcached has, so make sure
34
+ # it's listening on a firewalled interface.
35
+ #-l 127.0.0.1
36
+
37
+ # Limit the number of simultaneous incoming connections. The daemon default is 1024
38
+ # -c 1024
39
+
40
+ # Lock down all paged memory. Consult with the README and homepage before you do this
41
+ # -k
42
+
43
+ # Return error when memory is exhausted (rather than removing items)
44
+ # -M
45
+
46
+ # Maximize core file limit
47
+ # -r
@@ -0,0 +1,9 @@
1
+ ---
2
+ cwd: /mnt/app/current
3
+ port: "8000"
4
+ environment: production
5
+ pid_file: log/mongrel.pid
6
+ servers: 6
7
+ daemon: true
8
+ user: app
9
+ group: app
@@ -0,0 +1,71 @@
1
+ check process mongrel_8000 with pidfile /mnt/app/shared/log/mongrel.8000.pid
2
+ start program = "/usr/local/ec2onrails/bin/mongrel_start --only 8000"
3
+ stop program = "/usr/local/ec2onrails/bin/mongrel_stop --only 8000"
4
+ if totalmem is greater than 170.0 MB for 4 cycles then restart
5
+ if cpu is greater than 80% for 4 cycles then restart
6
+ if failed port 8000 with timeout 10 seconds then restart
7
+ if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
8
+ if loadavg(15min) greater than 8 for 20 cycles then restart # bad, bad, bad
9
+ if 20 restarts within 20 cycles then timeout
10
+ mode manual
11
+ group app
12
+
13
+ check process mongrel_8001 with pidfile /mnt/app/shared/log/mongrel.8001.pid
14
+ start program = "/usr/local/ec2onrails/bin/mongrel_start --only 8001"
15
+ stop program = "/usr/local/ec2onrails/bin/mongrel_stop --only 8001"
16
+ if totalmem is greater than 170.0 MB for 4 cycles then restart
17
+ if cpu is greater than 80% for 4 cycles then restart
18
+ if failed port 8001 with timeout 10 seconds then restart
19
+ if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
20
+ if loadavg(15min) greater than 8 for 20 cycles then restart # bad, bad, bad
21
+ if 20 restarts within 20 cycles then timeout
22
+ mode manual
23
+ group app
24
+
25
+ check process mongrel_8002 with pidfile /mnt/app/shared/log/mongrel.8002.pid
26
+ start program = "/usr/local/ec2onrails/bin/mongrel_start --only 8002"
27
+ stop program = "/usr/local/ec2onrails/bin/mongrel_stop --only 8002"
28
+ if totalmem is greater than 170.0 MB for 4 cycles then restart
29
+ if cpu is greater than 80% for 4 cycles then restart
30
+ if failed port 8002 with timeout 10 seconds then restart
31
+ if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
32
+ if loadavg(15min) greater than 8 for 20 cycles then restart # bad, bad, bad
33
+ if 20 restarts within 20 cycles then timeout
34
+ mode manual
35
+ group app
36
+
37
+ check process mongrel_8003 with pidfile /mnt/app/shared/log/mongrel.8003.pid
38
+ start program = "/usr/local/ec2onrails/bin/mongrel_start --only 8003"
39
+ stop program = "/usr/local/ec2onrails/bin/mongrel_stop --only 8003"
40
+ if totalmem is greater than 170.0 MB for 4 cycles then restart
41
+ if cpu is greater than 80% for 4 cycles then restart
42
+ if failed port 8003 with timeout 10 seconds then restart
43
+ if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
44
+ if loadavg(15min) greater than 8 for 20 cycles then restart # bad, bad, bad
45
+ if 20 restarts within 20 cycles then timeout
46
+ mode manual
47
+ group app
48
+
49
+ check process mongrel_8004 with pidfile /mnt/app/shared/log/mongrel.8004.pid
50
+ start program = "/usr/local/ec2onrails/bin/mongrel_start --only 8004"
51
+ stop program = "/usr/local/ec2onrails/bin/mongrel_stop --only 8004"
52
+ if totalmem is greater than 170.0 MB for 4 cycles then restart
53
+ if cpu is greater than 80% for 4 cycles then restart
54
+ if failed port 8004 with timeout 10 seconds then restart
55
+ if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
56
+ if loadavg(15min) greater than 8 for 20 cycles then restart # bad, bad, bad
57
+ if 20 restarts within 20 cycles then timeout
58
+ mode manual
59
+ group app
60
+
61
+ check process mongrel_8005 with pidfile /mnt/app/shared/log/mongrel.8005.pid
62
+ start program = "/usr/local/ec2onrails/bin/mongrel_start --only 8005"
63
+ stop program = "/usr/local/ec2onrails/bin/mongrel_stop --only 8005"
64
+ if totalmem is greater than 170.0 MB for 4 cycles then restart
65
+ if cpu is greater than 80% for 4 cycles then restart
66
+ if failed port 8005 with timeout 10 seconds then restart
67
+ if loadavg(5min) greater than 10 for 8 cycles then restart # bad, bad, bad
68
+ if loadavg(15min) greater than 8 for 20 cycles then restart # bad, bad, bad
69
+ if 20 restarts within 20 cycles then timeout
70
+ mode manual
71
+ group app
@@ -0,0 +1,10 @@
1
+ check process mysql with pidfile /var/run/mysqld/mysqld.pid
2
+ start program = "/etc/init.d/mysql start"
3
+ stop program = "/etc/init.d/mysql stop"
4
+ if cpu > 80% for 5 cycles then restart
5
+ # TODO: this should take into account the settings from the optimize_mysql call.....
6
+ # if totalmem > 700.0 MB for 5 cycles then restart
7
+ if failed port 3306 protocol mysql with timeout 10 seconds then alert
8
+ if 3 restarts within 5 cycles then timeout
9
+ mode manual
10
+ group db_primary
@@ -0,0 +1,8 @@
1
+ check process memcached with pidfile /var/run/memcached.pid
2
+ start program = "/etc/init.d/memcached start"
3
+ stop program = "/etc/init.d/memcached stop"
4
+ if cpu > 80% for 5 cycles then restart
5
+ if failed port 11211 with timeout 10 seconds then restart
6
+ if 3 restarts within 5 cycles then timeout
7
+ mode manual
8
+ group memcache
@@ -0,0 +1,13 @@
1
+ set daemon 60
2
+ set logfile syslog facility log_daemon
3
+ set mailserver localhost
4
+ set mail-format {
5
+ from: admin@localhost
6
+ subject: $HOST: $SERVICE $EVENT at $DATE
7
+ }
8
+ set alert admin@localhost only on { connection, exec, nonexist, resource, timeout }
9
+ set eventqueue basedir /var/monit slots 50
10
+ set httpd port 2812
11
+ # address localhost
12
+ allow localhost
13
+ include /etc/monit/*.monitrc
@@ -0,0 +1,15 @@
1
+ check system localhost
2
+ if loadavg (5min) > 4 then alert
3
+ if memory usage > 80% then alert
4
+
5
+ check device rootfs with path /
6
+ if space usage > 75 % then alert
7
+ if space usage > 95 % then unmonitor
8
+ if inode usage > 75 % then alert
9
+ if inode usage > 95 % then unmonitor
10
+
11
+ check device mntfs with path /mnt
12
+ if space usage > 70 % then alert
13
+ if space usage > 95 % then unmonitor
14
+ if inode usage > 70 % then alert
15
+ if inode usage > 95 % then unmonitor
@@ -0,0 +1,10 @@
1
+ check process apache with pidfile /var/run/apache2.pid
2
+ start program = "/etc/init.d/apache2 start"
3
+ stop program = "/etc/init.d/apache2 stop"
4
+ if cpu > 80% for 5 cycles then restart
5
+ if totalmem > 300.0 MB for 5 cycles then restart
6
+ if children > 250 then alert
7
+ if failed port 80 with timeout 10 seconds then restart
8
+ if 3 restarts within 5 cycles then timeout
9
+ mode manual
10
+ group web
@@ -0,0 +1,13 @@
1
+
2
+ EC2 on Rails
3
+ !!VERSION!!
4
+ http://rubyforge.org/projects/ec2onrails/
5
+
6
+ Copyright 2008 Paul Dowman, http://pauldowman.com/
7
+
8
+ Base AMI built using Eric Hammond's EC2 Ubuntu script:
9
+ http://alestic.com/
10
+
11
+ This is free software, and you are welcome to redistribute it under
12
+ certain conditions. This software comes with ABSOLUTELY NO WARRANTY.
13
+ See /usr/local/ec2onrails/COPYING for details.
@@ -0,0 +1,149 @@
1
+ #
2
+ # The MySQL database server configuration file.
3
+ #
4
+ # You can copy this to one of:
5
+ # - "/etc/mysql/my.cnf" to set global options,
6
+ # - "~/.my.cnf" to set user-specific options.
7
+ #
8
+ # One can use all long options that the program supports.
9
+ # Run program with --help to get a list of available options and with
10
+ # --print-defaults to see which it would actually understand and use.
11
+ #
12
+ # For explanations see
13
+ # http://dev.mysql.com/doc/mysql/en/server-system-variables.html
14
+
15
+ # This will be passed to all mysql clients
16
+ # It has been reported that passwords should be enclosed with ticks/quotes
17
+ # escpecially if they contain "#" chars...
18
+ # Remember to edit /etc/mysql/debian.cnf when changing the socket location.
19
+ [client]
20
+ port = 3306
21
+ socket = /var/run/mysqld/mysqld.sock
22
+
23
+ # Here is entries for some specific programs
24
+ # The following values assume you have at least 32M ram
25
+
26
+ # This was formally known as [safe_mysqld]. Both versions are currently parsed.
27
+ [mysqld_safe]
28
+ socket = /var/run/mysqld/mysqld.sock
29
+ nice = 0
30
+
31
+ [mysqld]
32
+ #
33
+ # * Basic Settings
34
+ #
35
+ user = mysql
36
+ pid-file = /var/run/mysqld/mysqld.pid
37
+ socket = /var/run/mysqld/mysqld.sock
38
+ port = 3306
39
+ basedir = /usr
40
+ datadir = /mnt/mysql_data
41
+ tmpdir = /mnt/mysql_data/tmp
42
+ language = /usr/share/mysql/english
43
+ skip-external-locking
44
+ default-storage-engine = InnoDB
45
+
46
+ #
47
+ # Instead of skip-networking the default is now to listen only on
48
+ # localhost which is more compatible and is not less secure.
49
+ #bind-address = 127.0.0.1
50
+ #
51
+ # * Fine Tuning
52
+ #
53
+ key_buffer_size = 16M
54
+ max_allowed_packet = 16M
55
+ thread_stack = 128K
56
+ thread_cache_size = 8
57
+ #max_connections = 100
58
+ #table_cache = 64
59
+ #thread_concurrency = 10
60
+ #
61
+ # * Query Cache Configuration
62
+ #
63
+ query_cache_limit = 1M
64
+ query_cache_size = 64M
65
+ #
66
+ # * Logging and Replication
67
+ #
68
+ # Both location gets rotated by the cronjob.
69
+ # Be aware that this log type is a performance killer.
70
+ #log = /var/log/mysql/mysql.log
71
+ #
72
+ # Error logging goes to syslog. This is a Debian improvement :)
73
+ #
74
+ # Here you can see queries with especially long duration
75
+ log_slow_queries = /mnt/log/mysql/mysql-slow.log
76
+ long_query_time = 2
77
+ # log-queries-not-using-indexes
78
+ #
79
+ # The following can be used as easy to replay backup logs or for replication.
80
+ #server-id = 1
81
+ log_bin = /mnt/log/mysql/mysql-bin.log
82
+ # WARNING: Using expire_logs_days without bin_log crashes the server! See README.Debian!
83
+ expire_logs_days = 10
84
+ max_binlog_size = 100M
85
+ #binlog_do_db = include_database_name
86
+ #binlog_ignore_db = include_database_name
87
+ #
88
+ # * BerkeleyDB
89
+ #
90
+ # Using BerkeleyDB is now discouraged as its support will cease in 5.1.12.
91
+ skip-bdb
92
+ #
93
+ # * InnoDB
94
+ #
95
+ # InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
96
+ # Read the manual for more InnoDB related options. There are many!
97
+ # You might want to disable InnoDB to shrink the mysqld process by circa 100MB.
98
+ #skip-innodb
99
+ innodb_data_file_path=ibdata1:100M:autoextend
100
+ innodb_buffer_pool_size=200M
101
+ innodb_additional_mem_pool_size=20M
102
+ innodb_log_file_size=128M
103
+ innodb_log_buffer_size=8M
104
+ innodb_flush_log_at_trx_commit=1
105
+ innodb_lock_wait_timeout=20
106
+ # innodb_flush_method=O_DIRECT
107
+ innodb_file_per_table
108
+
109
+ #
110
+ # * Security Features
111
+ #
112
+ # Read the manual, too, if you want chroot!
113
+ # chroot = /var/lib/mysql/
114
+ #
115
+ # For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
116
+ #
117
+ # ssl-ca=/etc/mysql/cacert.pem
118
+ # ssl-cert=/etc/mysql/server-cert.pem
119
+ # ssl-key=/etc/mysql/server-key.pem
120
+
121
+
122
+
123
+ [mysqldump]
124
+ quick
125
+ quote-names
126
+ max_allowed_packet = 16M
127
+
128
+ [mysql]
129
+ #no-auto-rehash # faster start of mysql but no tab completition
130
+
131
+ [isamchk]
132
+ key_buffer = 16M
133
+
134
+ #
135
+ # * NDB Cluster
136
+ #
137
+ # See /usr/share/doc/mysql-server-*/README.Debian for more information.
138
+ #
139
+ # The following configuration is read by the NDB Data Nodes (ndbd processes)
140
+ # not from the NDB Management Nodes (ndb_mgmd processes).
141
+ #
142
+ # [MYSQL_CLUSTER]
143
+ # ndb-connectstring=127.0.0.1
144
+
145
+
146
+ #
147
+ # * IMPORTANT: Additional settings that can override those from this file!
148
+ #
149
+ !includedir /etc/mysql/conf.d/
@@ -0,0 +1,4 @@
1
+ mynetworks_style = host
2
+ relay_domains =
3
+ inet_interfaces = 127.0.0.1
4
+ alias_maps = hash:/etc/aliases
@@ -0,0 +1,91 @@
1
+ #!/bin/sh -e
2
+
3
+ # This file is part of EC2 on Rails.
4
+ # http://rubyforge.org/projects/ec2onrails/
5
+ #
6
+ # Copyright 2007 Paul Dowman, http://pauldowman.com/
7
+ #
8
+ # EC2 on Rails is free software; you can redistribute it and/or modify
9
+ # it under the terms of the GNU General Public License as published by
10
+ # the Free Software Foundation; either version 2 of the License, or
11
+ # (at your option) any later version.
12
+ #
13
+ # EC2 on Rails is distributed in the hope that it will be useful,
14
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ # GNU General Public License for more details.
17
+ #
18
+ # You should have received a copy of the GNU General Public License
19
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
20
+
21
+
22
+ #
23
+ # This is the init script to start/stop mongrel
24
+ #
25
+
26
+ NAME="mongrel cluster"
27
+ NO_START=0
28
+
29
+ ########################################
30
+
31
+ if [ ! -d /mnt/app/current ] ; then
32
+ echo "/mnt/app/current doesn't exist, not starting mongrel..."
33
+ exit 0
34
+ fi
35
+
36
+ start_cmd() {
37
+ /usr/local/ec2onrails/bin/mongrel_start
38
+ return $?
39
+ }
40
+
41
+ stop_cmd() {
42
+ /usr/local/ec2onrails/bin/mongrel_stop
43
+ return $?
44
+ }
45
+
46
+ restart_cmd() {
47
+ /usr/local/ec2onrails/bin/mongrel_stop && /usr/local/ec2onrails/bin/mongrel_start
48
+ return $?
49
+ }
50
+
51
+
52
+ ########################################
53
+
54
+ . /lib/lsb/init-functions
55
+
56
+ test -f /etc/default/rcS && . /etc/default/rcS
57
+
58
+ if [ "$NO_START" != "0" -a "$1" != "stop" ]; then
59
+ [ "$VERBOSE" != no ] && log_warning_msg "Not starting $NAME - edit $0 and change NO_START to be 0.";
60
+ exit 0;
61
+ fi
62
+
63
+ case "$1" in
64
+ start)
65
+ log_begin_msg "Starting $NAME..."
66
+ if start_cmd; then
67
+ log_end_msg 0
68
+ else
69
+ log_end_msg 1
70
+ fi
71
+ ;;
72
+ stop)
73
+ log_begin_msg "Stopping $NAME..."
74
+ if stop_cmd; then
75
+ log_end_msg 0
76
+ else
77
+ log_end_msg 1
78
+ fi
79
+ ;;
80
+ restart)
81
+ log_begin_msg "Restarting $NAME..."
82
+ if restart_cmd; then
83
+ log_end_msg 0
84
+ else
85
+ log_end_msg 1
86
+ fi
87
+ ;;
88
+ *)
89
+ log_success_msg "Usage: $0 {start|stop|restart}"
90
+ ;;
91
+ esac