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.
- data/{History.txt → CHANGELOG} +0 -0
- data/{COPYING.txt → COPYING} +0 -0
- data/Manifest +161 -0
- data/{website/index.txt → README.textile} +33 -5
- data/Rakefile +36 -4
- data/TODO +91 -0
- data/ec2onrails.gemspec +279 -0
- data/examples/Capfile +3 -0
- data/examples/deploy.rb +88 -0
- data/examples/s3.yml +9 -0
- data/lib/ec2onrails/capistrano_utils.rb +0 -11
- data/lib/ec2onrails/recipes.rb +165 -59
- data/lib/ec2onrails/version.rb +1 -1
- data/server/build-ec2onrails.sh +44 -0
- data/server/files/etc/aliases +5 -0
- data/server/files/etc/aliases.db +0 -0
- data/server/files/etc/apache2/apache2.conf +295 -0
- data/server/files/etc/apache2/conf.d/app.proxy_cluster.conf +7 -0
- data/server/files/etc/apache2/conf.d/app.proxy_frontend.conf +10 -0
- data/server/files/etc/apache2/mods-available/proxy.conf +18 -0
- data/server/files/etc/apache2/sites-available/app.common +56 -0
- data/server/files/etc/apache2/sites-available/app.custom +0 -0
- data/server/files/etc/apache2/sites-available/default +14 -0
- data/server/files/etc/apache2/sites-available/default-ssl +18 -0
- data/server/files/etc/cron.d/backup_app_db_to_s3 +6 -0
- data/server/files/etc/cron.daily/app +9 -0
- data/server/files/etc/cron.daily/logrotate_post +19 -0
- data/server/files/etc/cron.hourly/app +10 -0
- data/server/files/etc/cron.monthly/app +10 -0
- data/server/files/etc/cron.weekly/app +10 -0
- data/server/files/etc/ec2onrails/balancer_members +6 -0
- data/server/files/etc/ec2onrails/roles.yml +5 -0
- data/server/files/etc/environment +2 -0
- data/server/files/etc/event.d/monit +13 -0
- data/server/files/etc/init.d/ec2-every-startup +29 -0
- data/server/files/etc/init.d/ec2-first-startup +36 -0
- data/server/files/etc/init.d/mongrel +91 -0
- data/server/files/etc/init.d/nginx +78 -0
- data/server/files/etc/init.d/set_roles +3 -0
- data/server/files/etc/logrotate.d/apache2 +16 -0
- data/server/files/etc/logrotate.d/mongrel +11 -0
- data/server/files/etc/logrotate.d/nginx +11 -0
- data/server/files/etc/memcached.conf +47 -0
- data/server/files/etc/mongrel_cluster/app.yml +9 -0
- data/server/files/etc/monit/README +5 -0
- data/server/files/etc/monit/app.monitrc.erb +13 -0
- data/server/files/etc/monit/db_primary.monitrc.erb +10 -0
- data/server/files/etc/monit/memcache.monitrc +8 -0
- data/server/files/etc/monit/monitrc +12 -0
- data/server/files/etc/monit/system.monitrc +15 -0
- data/server/files/etc/monit/web.monitrc.erb +23 -0
- data/server/files/etc/motd.tail +13 -0
- data/server/files/etc/mysql/my.cnf +149 -0
- data/server/files/etc/nginx/nginx.conf +296 -0
- data/server/files/etc/postfix/main.cf +4 -0
- data/server/files/etc/rc0.d/K10mongrel +1 -0
- data/server/files/etc/rc1.d/K10mongrel +1 -0
- data/server/files/etc/rc2.d/S90mongrel +1 -0
- data/server/files/etc/rc3.d/S90mongrel +1 -0
- data/server/files/etc/rc4.d/S90mongrel +1 -0
- data/server/files/etc/rc5.d/S90mongrel +1 -0
- data/server/files/etc/rc6.d/K10mongrel +1 -0
- data/server/files/etc/rcS.d/S91ec2-first-startup +1 -0
- data/server/files/etc/rcS.d/S92ec2-every-startup +1 -0
- data/server/files/etc/rcS.d/S99set_roles +1 -0
- data/server/files/etc/ssh/sshd_config +94 -0
- data/server/files/etc/sudoers +1 -0
- data/server/files/etc/sudoers.full_access +26 -0
- data/server/files/etc/sudoers.restricted_access +28 -0
- data/server/files/etc/syslog.conf +69 -0
- data/server/files/usr/local/ec2onrails/COPYING +339 -0
- data/server/files/usr/local/ec2onrails/bin/archive_file.rb +44 -0
- data/server/files/usr/local/ec2onrails/bin/backup_app_db.rb +68 -0
- data/server/files/usr/local/ec2onrails/bin/init_services.rb +57 -0
- data/server/files/usr/local/ec2onrails/bin/mongrel_start +8 -0
- data/server/files/usr/local/ec2onrails/bin/mongrel_stop +8 -0
- data/server/files/usr/local/ec2onrails/bin/optimize_mysql.rb +339 -0
- data/server/files/usr/local/ec2onrails/bin/rails_env +35 -0
- data/server/files/usr/local/ec2onrails/bin/rebundle.sh +70 -0
- data/server/files/usr/local/ec2onrails/bin/restore_app_db.rb +58 -0
- data/server/files/usr/local/ec2onrails/bin/set_rails_env +40 -0
- data/server/files/usr/local/ec2onrails/bin/set_roles.rb +76 -0
- data/server/files/usr/local/ec2onrails/bin/setup_web_proxy.rb +106 -0
- data/server/files/usr/local/ec2onrails/config +30 -0
- data/server/files/usr/local/ec2onrails/lib/mysql_helper.rb +82 -0
- data/server/files/usr/local/ec2onrails/lib/roles_helper.rb +137 -0
- data/server/files/usr/local/ec2onrails/lib/s3_helper.rb +126 -0
- data/server/files/usr/local/ec2onrails/lib/utils.rb +16 -0
- data/server/files/usr/local/ec2onrails/lib/vendor/ini.rb +268 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/every-startup/get-hostname.sh +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/README +5 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs.sh +42 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key.sh +49 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc.sh +27 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh +24 -0
- data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials.sh +29 -0
- data/server/rakefile.rb +222 -0
- data/test/autobench.conf +60 -0
- data/test/spec/lib/s3_helper_spec.rb +134 -0
- data/test/spec/lib/s3_old.yml +3 -0
- data/test/spec/test_files/test1 +0 -0
- data/test/spec/test_files/test2 +0 -0
- data/test/test_app/Capfile +3 -0
- data/test/test_app/README +182 -0
- data/test/test_app/Rakefile +10 -0
- data/test/test_app/app/controllers/application.rb +7 -0
- data/test/test_app/app/controllers/db_fast_controller.rb +6 -0
- data/test/test_app/app/controllers/fast_controller.rb +5 -0
- data/test/test_app/app/controllers/slow_controller.rb +6 -0
- data/test/test_app/app/controllers/very_slow_controller.rb +6 -0
- data/test/test_app/app/helpers/application_helper.rb +3 -0
- data/test/test_app/app/helpers/db_fast_helper.rb +2 -0
- data/test/test_app/app/helpers/fast_helper.rb +2 -0
- data/test/test_app/app/helpers/slow_helper.rb +2 -0
- data/test/test_app/app/helpers/very_slow_helper.rb +2 -0
- data/test/test_app/config/boot.rb +109 -0
- data/test/test_app/config/database.yml +19 -0
- data/test/test_app/config/deploy.rb +21 -0
- data/test/test_app/config/environment.rb +60 -0
- data/test/test_app/config/environments/development.rb +21 -0
- data/test/test_app/config/environments/production.rb +18 -0
- data/test/test_app/config/environments/test.rb +19 -0
- data/test/test_app/config/routes.rb +27 -0
- data/test/test_app/db/schema.rb +7 -0
- data/test/test_app/doc/README_FOR_APP +2 -0
- data/test/test_app/public/404.html +30 -0
- data/test/test_app/public/500.html +30 -0
- data/test/test_app/public/dispatch.cgi +10 -0
- data/test/test_app/public/dispatch.fcgi +24 -0
- data/test/test_app/public/dispatch.rb +10 -0
- data/test/test_app/public/favicon.ico +0 -0
- data/test/test_app/public/images/rails.png +0 -0
- data/test/test_app/public/javascripts/application.js +2 -0
- data/test/test_app/public/javascripts/controls.js +963 -0
- data/test/test_app/public/javascripts/dragdrop.js +972 -0
- data/test/test_app/public/javascripts/effects.js +1120 -0
- data/test/test_app/public/javascripts/prototype.js +4225 -0
- data/test/test_app/public/robots.txt +1 -0
- data/test/test_app/script/about +3 -0
- data/test/test_app/script/breakpointer +3 -0
- data/test/test_app/script/console +3 -0
- data/test/test_app/script/destroy +3 -0
- data/test/test_app/script/generate +3 -0
- data/test/test_app/script/performance/benchmarker +3 -0
- data/test/test_app/script/performance/profiler +3 -0
- data/test/test_app/script/performance/request +3 -0
- data/test/test_app/script/plugin +3 -0
- data/test/test_app/script/process/inspector +3 -0
- data/test/test_app/script/process/reaper +3 -0
- data/test/test_app/script/process/spawner +3 -0
- data/test/test_app/script/runner +3 -0
- data/test/test_app/script/server +3 -0
- data/test/test_app/test/functional/db_fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/fast_controller_test.rb +18 -0
- data/test/test_app/test/functional/slow_controller_test.rb +18 -0
- data/test/test_app/test/functional/very_slow_controller_test.rb +18 -0
- metadata +193 -36
- data/Manifest.txt +0 -25
- data/README.txt +0 -1
- data/config/hoe.rb +0 -70
- data/config/requirements.rb +0 -17
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/script/txt2html +0 -74
- data/tasks/deployment.rake +0 -27
- data/tasks/environment.rake +0 -7
- data/tasks/website.rake +0 -17
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -144
- 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,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
|
data/server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir.sh
ADDED
@@ -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
|
data/server/rakefile.rb
ADDED
@@ -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
|
data/test/autobench.conf
ADDED
@@ -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
|