Agiley-ec2onrails 0.9.9 → 0.9.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (170) hide show
  1. data/{History.txt → CHANGELOG} +0 -0
  2. data/{COPYING.txt → COPYING} +0 -0
  3. data/Manifest +161 -0
  4. data/{website/index.txt → README.textile} +33 -5
  5. data/Rakefile +36 -4
  6. data/TODO +91 -0
  7. data/ec2onrails.gemspec +279 -0
  8. data/examples/Capfile +3 -0
  9. data/examples/deploy.rb +88 -0
  10. data/examples/s3.yml +9 -0
  11. data/lib/ec2onrails/capistrano_utils.rb +0 -11
  12. data/lib/ec2onrails/recipes.rb +165 -59
  13. data/lib/ec2onrails/version.rb +1 -1
  14. data/server/build-ec2onrails.sh +44 -0
  15. data/server/files/etc/aliases +5 -0
  16. data/server/files/etc/aliases.db +0 -0
  17. data/server/files/etc/apache2/apache2.conf +295 -0
  18. data/server/files/etc/apache2/conf.d/app.proxy_cluster.conf +7 -0
  19. data/server/files/etc/apache2/conf.d/app.proxy_frontend.conf +10 -0
  20. data/server/files/etc/apache2/mods-available/proxy.conf +18 -0
  21. data/server/files/etc/apache2/sites-available/app.common +56 -0
  22. data/server/files/etc/apache2/sites-available/app.custom +0 -0
  23. data/server/files/etc/apache2/sites-available/default +14 -0
  24. data/server/files/etc/apache2/sites-available/default-ssl +18 -0
  25. data/server/files/etc/cron.d/backup_app_db_to_s3 +6 -0
  26. data/server/files/etc/cron.daily/app +9 -0
  27. data/server/files/etc/cron.daily/logrotate_post +19 -0
  28. data/server/files/etc/cron.hourly/app +10 -0
  29. data/server/files/etc/cron.monthly/app +10 -0
  30. data/server/files/etc/cron.weekly/app +10 -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/nginx +78 -0
  39. data/server/files/etc/init.d/set_roles +3 -0
  40. data/server/files/etc/logrotate.d/apache2 +16 -0
  41. data/server/files/etc/logrotate.d/mongrel +11 -0
  42. data/server/files/etc/logrotate.d/nginx +11 -0
  43. data/server/files/etc/memcached.conf +47 -0
  44. data/server/files/etc/mongrel_cluster/app.yml +9 -0
  45. data/server/files/etc/monit/README +5 -0
  46. data/server/files/etc/monit/app.monitrc.erb +13 -0
  47. data/server/files/etc/monit/db_primary.monitrc.erb +10 -0
  48. data/server/files/etc/monit/memcache.monitrc +8 -0
  49. data/server/files/etc/monit/monitrc +12 -0
  50. data/server/files/etc/monit/system.monitrc +15 -0
  51. data/server/files/etc/monit/web.monitrc.erb +23 -0
  52. data/server/files/etc/motd.tail +13 -0
  53. data/server/files/etc/mysql/my.cnf +149 -0
  54. data/server/files/etc/nginx/nginx.conf +296 -0
  55. data/server/files/etc/postfix/main.cf +4 -0
  56. data/server/files/etc/rc0.d/K10mongrel +1 -0
  57. data/server/files/etc/rc1.d/K10mongrel +1 -0
  58. data/server/files/etc/rc2.d/S90mongrel +1 -0
  59. data/server/files/etc/rc3.d/S90mongrel +1 -0
  60. data/server/files/etc/rc4.d/S90mongrel +1 -0
  61. data/server/files/etc/rc5.d/S90mongrel +1 -0
  62. data/server/files/etc/rc6.d/K10mongrel +1 -0
  63. data/server/files/etc/rcS.d/S91ec2-first-startup +1 -0
  64. data/server/files/etc/rcS.d/S92ec2-every-startup +1 -0
  65. data/server/files/etc/rcS.d/S99set_roles +1 -0
  66. data/server/files/etc/ssh/sshd_config +94 -0
  67. data/server/files/etc/sudoers +1 -0
  68. data/server/files/etc/sudoers.full_access +26 -0
  69. data/server/files/etc/sudoers.restricted_access +28 -0
  70. data/server/files/etc/syslog.conf +69 -0
  71. data/server/files/usr/local/ec2onrails/COPYING +339 -0
  72. data/server/files/usr/local/ec2onrails/bin/archive_file.rb +44 -0
  73. data/server/files/usr/local/ec2onrails/bin/backup_app_db.rb +68 -0
  74. data/server/files/usr/local/ec2onrails/bin/init_services.rb +57 -0
  75. data/server/files/usr/local/ec2onrails/bin/mongrel_start +8 -0
  76. data/server/files/usr/local/ec2onrails/bin/mongrel_stop +8 -0
  77. data/server/files/usr/local/ec2onrails/bin/optimize_mysql.rb +339 -0
  78. data/server/files/usr/local/ec2onrails/bin/rails_env +35 -0
  79. data/server/files/usr/local/ec2onrails/bin/rebundle.sh +70 -0
  80. data/server/files/usr/local/ec2onrails/bin/restore_app_db.rb +58 -0
  81. data/server/files/usr/local/ec2onrails/bin/set_rails_env +40 -0
  82. data/server/files/usr/local/ec2onrails/bin/set_roles.rb +76 -0
  83. data/server/files/usr/local/ec2onrails/bin/setup_web_proxy.rb +106 -0
  84. data/server/files/usr/local/ec2onrails/config +30 -0
  85. data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +82 -0
  86. data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +137 -0
  87. data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +126 -0
  88. data/server/files/usr/local/ec2onrails/lib/utils.rb +16 -0
  89. data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
  90. data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/get-hostname.sh +27 -0
  91. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/README +5 -0
  92. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs.sh +42 -0
  93. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key.sh +49 -0
  94. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc.sh +27 -0
  95. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh +24 -0
  96. data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials.sh +29 -0
  97. data/server/rakefile.rb +222 -0
  98. data/test/autobench.conf +60 -0
  99. data/test/spec/lib/s3_helper_spec.rb +134 -0
  100. data/test/spec/lib/s3_old.yml +3 -0
  101. data/test/spec/test_files/test1 +0 -0
  102. data/test/spec/test_files/test2 +0 -0
  103. data/test/test_app/Capfile +3 -0
  104. data/test/test_app/README +182 -0
  105. data/test/test_app/Rakefile +10 -0
  106. data/test/test_app/app/controllers/application.rb +7 -0
  107. data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
  108. data/test/test_app/app/controllers/fast_controller.rb +5 -0
  109. data/test/test_app/app/controllers/slow_controller.rb +6 -0
  110. data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
  111. data/test/test_app/app/helpers/application_helper.rb +3 -0
  112. data/test/test_app/app/helpers/db_fast_helper.rb +2 -0
  113. data/test/test_app/app/helpers/fast_helper.rb +2 -0
  114. data/test/test_app/app/helpers/slow_helper.rb +2 -0
  115. data/test/test_app/app/helpers/very_slow_helper.rb +2 -0
  116. data/test/test_app/config/boot.rb +109 -0
  117. data/test/test_app/config/database.yml +19 -0
  118. data/test/test_app/config/deploy.rb +21 -0
  119. data/test/test_app/config/environment.rb +60 -0
  120. data/test/test_app/config/environments/development.rb +21 -0
  121. data/test/test_app/config/environments/production.rb +18 -0
  122. data/test/test_app/config/environments/test.rb +19 -0
  123. data/test/test_app/config/routes.rb +27 -0
  124. data/test/test_app/db/schema.rb +7 -0
  125. data/test/test_app/doc/README_FOR_APP +2 -0
  126. data/test/test_app/public/404.html +30 -0
  127. data/test/test_app/public/500.html +30 -0
  128. data/test/test_app/public/dispatch.cgi +10 -0
  129. data/test/test_app/public/dispatch.fcgi +24 -0
  130. data/test/test_app/public/dispatch.rb +10 -0
  131. data/test/test_app/public/favicon.ico +0 -0
  132. data/test/test_app/public/images/rails.png +0 -0
  133. data/test/test_app/public/javascripts/application.js +2 -0
  134. data/test/test_app/public/javascripts/controls.js +963 -0
  135. data/test/test_app/public/javascripts/dragdrop.js +972 -0
  136. data/test/test_app/public/javascripts/effects.js +1120 -0
  137. data/test/test_app/public/javascripts/prototype.js +4225 -0
  138. data/test/test_app/public/robots.txt +1 -0
  139. data/test/test_app/script/about +3 -0
  140. data/test/test_app/script/breakpointer +3 -0
  141. data/test/test_app/script/console +3 -0
  142. data/test/test_app/script/destroy +3 -0
  143. data/test/test_app/script/generate +3 -0
  144. data/test/test_app/script/performance/benchmarker +3 -0
  145. data/test/test_app/script/performance/profiler +3 -0
  146. data/test/test_app/script/performance/request +3 -0
  147. data/test/test_app/script/plugin +3 -0
  148. data/test/test_app/script/process/inspector +3 -0
  149. data/test/test_app/script/process/reaper +3 -0
  150. data/test/test_app/script/process/spawner +3 -0
  151. data/test/test_app/script/runner +3 -0
  152. data/test/test_app/script/server +3 -0
  153. data/test/test_app/test/functional/db_fast_controller_test.rb +18 -0
  154. data/test/test_app/test/functional/fast_controller_test.rb +18 -0
  155. data/test/test_app/test/functional/slow_controller_test.rb +18 -0
  156. data/test/test_app/test/functional/very_slow_controller_test.rb +18 -0
  157. metadata +193 -36
  158. data/Manifest.txt +0 -25
  159. data/README.txt +0 -1
  160. data/config/hoe.rb +0 -70
  161. data/config/requirements.rb +0 -17
  162. data/script/destroy +0 -14
  163. data/script/generate +0 -14
  164. data/script/txt2html +0 -74
  165. data/tasks/deployment.rake +0 -27
  166. data/tasks/environment.rake +0 -7
  167. data/tasks/website.rake +0 -17
  168. data/website/javascripts/rounded_corners_lite.inc.js +0 -285
  169. data/website/stylesheets/screen.css +0 -144
  170. data/website/template.rhtml +0 -53
@@ -0,0 +1,27 @@
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
+ # Set the hostname to this instance's public hostname
22
+ HOSTNAME=`curl http://169.254.169.254/latest/meta-data/public-hostname`
23
+
24
+ hostname $HOSTNAME
25
+
26
+ #echo $HOSTNAME > /etc/hostname
27
+
@@ -0,0 +1,5 @@
1
+ These files are called by /etc/init.d/ec2-first-startup.
2
+
3
+ They are launched via rcS.d, meaning they will be launched before OTHER
4
+ Ec2 scripts, like ec2-get-credentials... so if need some of those scripts
5
+ run before, call them manually
@@ -0,0 +1,42 @@
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
+ make_dir() {
22
+ mkdir -p $1
23
+ if [ $2 ] ; then
24
+ chown -R $2 $1
25
+ fi
26
+ }
27
+
28
+ make_dir /mnt/app app:app
29
+
30
+ #make sure it is setup to be able to be read/written by app user
31
+ make_dir /etc/ec2onrails app:app
32
+
33
+ make_dir /mnt/log
34
+ # make_dir /mnt/log/apache2 www-data:www-data
35
+ make_dir /mnt/log/fsck
36
+ make_dir /mnt/log/mysql mysql:mysql
37
+
38
+ make_dir /mnt/mysql_data mysql:mysql
39
+ make_dir /mnt/mysql_data/tmp mysql:mysql
40
+
41
+ make_dir /mnt/tmp
42
+ chmod 777 /mnt/tmp
@@ -0,0 +1,49 @@
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
+ # Generate a new self-signed cert and key for https
23
+
24
+ echo "Generating default self-signed SSL cert and key..."
25
+
26
+ export RANDFILE=/tmp/randfile
27
+
28
+ cd /tmp
29
+ openssl genrsa -out server.key 1024
30
+ openssl req -new -key server.key -out server.csr <<END
31
+ CA
32
+ .
33
+ .
34
+ .
35
+ .
36
+ .
37
+ .
38
+ .
39
+ .
40
+
41
+ END
42
+ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
43
+
44
+ mkdir -p /etc/ec2onrails/ssl/cert
45
+ mkdir -p -m 700 /etc/ec2onrails/ssl/private
46
+ mv server.key /etc/ec2onrails/ssl/private/ec2onrails-default.key
47
+ mv server.crt /etc/ec2onrails/ssl/cert/ec2onrails-default.crt
48
+ rm $RANDFILE
49
+ rm server.csr
@@ -0,0 +1,27 @@
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
+ cp /etc/hosts /etc/hosts.original
23
+
24
+ # make sure the db optimize is only run once...
25
+ # the setup script will look for this flag, and
26
+ # if it doesn't exist the db optimzation won't occur
27
+ touch /tmp/optimize_db_flag
@@ -0,0 +1,24 @@
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
+ mkdir -p /mnt/mysql_data/tmp
23
+ chown -R mysql:mysql /mnt/mysql_data/
24
+ cp -rp /var/lib/mysql/mysql /mnt/mysql_data/
@@ -0,0 +1,29 @@
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
+ # This file helps spread the root key so we can log in/deploy using the
22
+ # app user instead of root, but with the same ec2 key
23
+
24
+ #make sure we have the credentials
25
+ /etc/init.d/ec2-get-credentials
26
+
27
+ mkdir -p -m 700 /home/app/.ssh
28
+ cp /root/.ssh/authorized_keys /home/app/.ssh
29
+ chown -R app:app /home/app/.ssh
@@ -0,0 +1,222 @@
1
+ # This file is part of EC2 on Rails.
2
+ # http://rubyforge.org/projects/ec2onrails/
3
+ #
4
+ # Copyright 2007 Paul Dowman, http://pauldowman.com/
5
+ #
6
+ # EC2 on Rails is free software; you can redistribute it and/or modify
7
+ # it under the terms of the GNU General Public License as published by
8
+ # the Free Software Foundation; either version 2 of the License, or
9
+ # (at your option) any later version.
10
+ #
11
+ # EC2 on Rails is distributed in the hope that it will be useful,
12
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
+ # GNU General Public License for more details.
15
+ #
16
+ # You should have received a copy of the GNU General Public License
17
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
18
+
19
+
20
+ # This script is meant to be run by build-ec2onrails.sh, which is run by
21
+ # Eric Hammond's Ubuntu build script: http://alestic.com/
22
+ # e.g.:
23
+ # bash /mnt/ec2ubuntu-build-ami --script /mnt/ec2onrails/server/build-ec2onrails.sh ...
24
+
25
+
26
+
27
+ require "rake/clean"
28
+ require 'yaml'
29
+ require 'erb'
30
+ require "#{File.dirname(__FILE__)}/../lib/ec2onrails/version"
31
+
32
+ if `whoami`.strip != 'root'
33
+ raise "Sorry, this buildfile must be run as root."
34
+ end
35
+
36
+ @packages = %w(
37
+ adduser
38
+ apache2
39
+ aptitude
40
+ bison
41
+ ca-certificates
42
+ cron
43
+ curl
44
+ denyhosts # security: ssh monitoring service
45
+ flex
46
+ gcc
47
+ git-core
48
+ irb
49
+ less
50
+ libdbm-ruby
51
+ libgdbm-ruby
52
+ libmysql-ruby
53
+ libopenssl-ruby
54
+ libreadline-ruby
55
+ libruby
56
+ libssl-dev
57
+ libyaml-ruby
58
+ libzlib-ruby
59
+ logrotate
60
+ make
61
+ mailx
62
+ memcached
63
+ mysql-client
64
+ mysql-server
65
+ nano
66
+ openssh-server
67
+ postfix
68
+ rdoc
69
+ ri
70
+ rsync
71
+ ruby
72
+ ruby1.8-dev
73
+ subversion
74
+ unzip
75
+ vim
76
+ wget
77
+ )
78
+
79
+ @rubygems = [
80
+ "amazon-ec2",
81
+ "aws-s3",
82
+ "memcache-client",
83
+ "mongrel",
84
+ "mongrel_cluster",
85
+ "optiflag",
86
+ "rails",
87
+ "rails -v 2.0.2",
88
+ "rails -v 1.2.6",
89
+ "rake"
90
+ ]
91
+
92
+ @build_root = "/mnt/build"
93
+ @fs_dir = "#{@build_root}/ubuntu"
94
+
95
+ @version = [Ec2onrails::VERSION::MAJOR, Ec2onrails::VERSION::MINOR, Ec2onrails::VERSION::TINY].join('.')
96
+
97
+ task :default => :configure
98
+
99
+ desc "Removes all build files"
100
+ task :clean_all do |t|
101
+ rm_rf @build_root
102
+ end
103
+
104
+ desc "Use apt-get to install required packages inside the image's filesystem"
105
+ task :install_packages do |t|
106
+ unless_completed(t) do
107
+ #why is this commented out?
108
+ #ENV['DEBIAN_FRONTEND'] = 'noninteractive'
109
+ ENV['LANG'] = ''
110
+ run_chroot "apt-get install -y #{@packages.join(' ')}"
111
+ run_chroot "apt-get clean"
112
+ end
113
+ end
114
+
115
+ desc "Install required ruby gems inside the image's filesystem"
116
+ task :install_gems => [:install_packages] do |t|
117
+ unless_completed(t) do
118
+ run_chroot "sh -c 'cd /tmp && wget -q http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz && tar zxf rubygems-1.2.0.tgz'"
119
+ run_chroot "sh -c 'cd /tmp/rubygems-1.2.0 && ruby setup.rb'"
120
+ run_chroot "ln -sf /usr/bin/gem1.8 /usr/bin/gem"
121
+ run_chroot "gem update --system --no-rdoc --no-ri"
122
+ run_chroot "gem update --no-rdoc --no-ri"
123
+ @rubygems.each do |gem|
124
+ run_chroot "gem install #{gem} --no-rdoc --no-ri"
125
+ end
126
+ end
127
+ end
128
+
129
+ desc "Compile and install monit"
130
+ task :install_monit => [:install_packages] do |t|
131
+ unless_completed(t) do
132
+ run_chroot "sh -c 'cd /tmp && wget -q http://www.tildeslash.com/monit/dist/monit-4.10.1.tar.gz'"
133
+ run_chroot "sh -c 'cd /tmp && tar xzvf monit-4.10.1.tar.gz'"
134
+ run_chroot "sh -c 'cd /tmp/monit-4.10.1 && ./configure --sysconfdir=/etc/monit/ --localstatedir=/var/run && make && make install'"
135
+ end
136
+ end
137
+
138
+ desc "Configure the image"
139
+ task :configure => [:install_gems, :install_monit] do |t|
140
+ unless_completed(t) do
141
+ sh("cp -r files/* #{@fs_dir}")
142
+ sh("find #{@fs_dir} -type d -name .svn | xargs rm -rf")
143
+
144
+ replace("#{@fs_dir}/etc/motd.tail", /!!VERSION!!/, "Version #{@version}")
145
+
146
+ run_chroot "/usr/sbin/adduser --gecos ',,,' --disabled-password app"
147
+
148
+ run "echo '. /usr/local/ec2onrails/config' >> #{@fs_dir}/root/.bashrc"
149
+ run "echo '. /usr/local/ec2onrails/config' >> #{@fs_dir}/home/app/.bashrc"
150
+
151
+ %w(mysql auth.log daemon.log kern.log mail.err mail.info mail.log mail.warn syslog user.log).each do |f|
152
+ rm_rf "#{@fs_dir}/var/log/#{f}"
153
+ run_chroot "ln -sf /mnt/log/#{f} /var/log/#{f}"
154
+ end
155
+
156
+ run "touch #{@fs_dir}/ec2onrails-first-boot"
157
+
158
+ # TODO find out the most correct solution here, there seems to be a bug in
159
+ # both feisty and gutsy where the dhcp daemon runs as dhcp but the dir
160
+ # that it tries to write to is owned by root and not writable by others.
161
+ run_chroot "chown -R dhcp /var/lib/dhcp3"
162
+ end
163
+ end
164
+
165
+ desc "This task is for deploying the contents of /files to a running server image to test config file changes without rebuilding."
166
+ task :deploy_files do |t|
167
+ raise "need 'key' and 'host' env vars defined" unless ENV['key'] && ENV['host']
168
+ run "rsync -rlvzcC --rsh='ssh -l root -i #{ENV['key']}' files/ #{ENV['host']}:/"
169
+ end
170
+
171
+ ##################
172
+
173
+ # Execute a given block and touch a stampfile. The block won't be run if the stampfile exists.
174
+ def unless_completed(task, &proc)
175
+ stampfile = "#{@build_root}/#{task.name}.completed"
176
+ unless File.exists?(stampfile)
177
+ yield
178
+ touch stampfile
179
+ end
180
+ end
181
+
182
+ def run_chroot(command, ignore_error = false)
183
+ run "chroot '#{@fs_dir}' #{command}", ignore_error
184
+ end
185
+
186
+ def run(command, ignore_error = false)
187
+ puts "*** #{command}"
188
+ result = system command
189
+ raise("error: #{$?}") unless result || ignore_error
190
+ end
191
+
192
+ # def mount(type, mount_point)
193
+ # unless mounted?(mount_point)
194
+ # puts
195
+ # puts "********** Mounting #{type} on #{mount_point}..."
196
+ # puts
197
+ # run "mount -t #{type} none #{mount_point}"
198
+ # end
199
+ # end
200
+ #
201
+ # def mounted?(mount_point)
202
+ # mount_point_regex = mount_point.gsub(/\//, "\\/")
203
+ # `mount`.select {|line| line.match(/#{mount_point_regex}/) }.any?
204
+ # end
205
+
206
+ def replace_line(file, newline, linenum)
207
+ contents = File.open(file, 'r').readlines
208
+ contents[linenum - 1] = newline
209
+ File.open(file, 'w') do |f|
210
+ contents.each {|line| f << line}
211
+ end
212
+ end
213
+
214
+ def replace(file, pattern, text)
215
+ contents = File.open(file, 'r').readlines
216
+ contents.each do |line|
217
+ line.gsub!(pattern, text)
218
+ end
219
+ File.open(file, 'w') do |f|
220
+ contents.each {|line| f << line}
221
+ end
222
+ end
@@ -0,0 +1,60 @@
1
+ # Autobench Configuration File
2
+
3
+ # host1, host2
4
+ # The hostnames of the servers under test
5
+ # Eg. host1 = iis.test.com
6
+ # host2 = apache.test.com
7
+
8
+ file = out.tsv
9
+
10
+ host1 = ec2-67-202-61-243.compute-1.amazonaws.com
11
+
12
+ # uri1, uri2
13
+ # The URI to test (relative to the document root). For a fair comparison
14
+ # the files should be identical (although the paths to them may differ on the
15
+ # different hosts)
16
+
17
+ uri1 = /
18
+
19
+ # port1, port2
20
+ # The port number on which the servers are listening
21
+
22
+ port1 = 80
23
+
24
+ # low_rate, high_rate, rate_step
25
+ # The 'rate' is the number of number of connections to open per second.
26
+ # A series of tests will be conducted, starting at low rate,
27
+ # increasing by rate step, and finishing at high_rate.
28
+ # The default settings test at rates of 20,30,40,50...180,190,200
29
+
30
+ low_rate = 1
31
+ high_rate = 5
32
+ rate_step = 1
33
+
34
+ # num_conn, num_call
35
+ # num_conn is the total number of connections to make during a test
36
+ # num_call is the number of requests per connection
37
+ # The product of num_call and rate is the the approximate number of
38
+ # requests per second that will be attempted.
39
+
40
+ num_conn = 1000
41
+ num_call = 5
42
+
43
+ # timeout sets the maximimum time (in seconds) that httperf will wait
44
+ # for replies from the web server. If the timeout is exceeded, the
45
+ # reply concerned is counted as an error.
46
+
47
+ timeout = 10
48
+
49
+ # output_fmt
50
+ # sets the output type - may be either "csv", or "tsv";
51
+
52
+ output_fmt = tsv
53
+
54
+ ## Config for distributed autobench (autobench_admin)
55
+ # clients
56
+ # comma separated list of the hostnames and portnumbers for the
57
+ # autobench clients. No whitespace can appear before or after the commas.
58
+ # clients = bench1.foo.com:4600,bench2.foo.com:4600,bench3.foo.com:4600
59
+
60
+ #clients = localhost:4600