pauldowman-ec2onrails 0.9.10.0 → 0.9.10.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -23,6 +23,8 @@ server/files/etc/cron.daily/logrotate_post
23
23
  server/files/etc/cron.hourly/app
24
24
  server/files/etc/cron.monthly/app
25
25
  server/files/etc/cron.weekly/app
26
+ server/files/etc/default/varnish
27
+ server/files/etc/default/varnishncsa
26
28
  server/files/etc/denyhosts.conf
27
29
  server/files/etc/dpkg/dpkg.cfg
28
30
  server/files/etc/ec2onrails/rails_env
@@ -35,6 +37,7 @@ server/files/etc/god/examples/have_god_daemonize.god
35
37
  server/files/etc/god/master.conf
36
38
  server/files/etc/god/memcache.god
37
39
  server/files/etc/god/notifications.god
40
+ server/files/etc/god/proxy.god
38
41
  server/files/etc/god/system.god
39
42
  server/files/etc/god/web.god
40
43
  server/files/etc/init.d/ec2-every-startup
@@ -45,18 +48,20 @@ server/files/etc/logrotate.d/nginx
45
48
  server/files/etc/memcached.conf
46
49
  server/files/etc/motd.tail
47
50
  server/files/etc/mysql/my.cnf
48
- server/files/etc/nginx/custom.conf
51
+ server/files/etc/nginx/conf.d/custom.conf
49
52
  server/files/etc/nginx/nginx.conf.erb
50
53
  server/files/etc/postfix/main.cf
51
54
  server/files/etc/README
52
55
  server/files/etc/ssh/sshd_config
53
56
  server/files/etc/sudoers
54
57
  server/files/etc/syslog.conf
58
+ server/files/etc/varnish/default.vcl.erb
55
59
  server/files/usr/local/ec2onrails/bin/archive_file
56
60
  server/files/usr/local/ec2onrails/bin/backup_app_db
57
61
  server/files/usr/local/ec2onrails/bin/backup_dir
58
62
  server/files/usr/local/ec2onrails/bin/ec2_meta_data
59
63
  server/files/usr/local/ec2onrails/bin/exec_runner
64
+ server/files/usr/local/ec2onrails/bin/in_role
60
65
  server/files/usr/local/ec2onrails/bin/init_services
61
66
  server/files/usr/local/ec2onrails/bin/install_system_files
62
67
  server/files/usr/local/ec2onrails/bin/optimize_mysql
data/Rakefile CHANGED
@@ -10,7 +10,12 @@ end
10
10
  require "./echoe_config"
11
11
 
12
12
  desc "Run all gem-related tasks"
13
- task :ec2onrails_gem => [:manifest, :package, :update_github_gemspec]
13
+ task :ec2onrails_gem => [:delete_ignored_files, :manifest, :package, :update_github_gemspec]
14
+
15
+ desc "Delete files that are in .gitignore so they don't get added to the manifest"
16
+ task :delete_ignored_files do
17
+ File.read(".gitignore").each { |line| FileUtils.rm_f Dir.glob(line.strip) }
18
+ end
14
19
 
15
20
  desc "Update the GitHub gemspec file (/ec2onrails.gemspec)"
16
21
  task :update_github_gemspec => [:manifest, :package] do
data/ec2onrails.gemspec CHANGED
@@ -5,21 +5,20 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{ec2onrails}
8
- s.version = "0.9.10.0"
8
+ s.version = "0.9.10.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Paul Dowman, Adam Greene"]
12
- s.date = %q{2009-06-29}
12
+ s.date = %q{2009-07-07}
13
13
  s.description = %q{Client-side libraries (Capistrano tasks) for managing and deploying to EC2 on Rails servers.}
14
14
  s.email = %q{paul@pauldowman.com}
15
15
  s.extra_rdoc_files = ["CHANGELOG", "lib/ec2onrails/capistrano_utils.rb", "lib/ec2onrails/recipes/db.rb", "lib/ec2onrails/recipes/deploy.rb", "lib/ec2onrails/recipes/server.rb", "lib/ec2onrails/recipes.rb", "lib/ec2onrails/version.rb", "lib/ec2onrails.rb", "README.textile"]
16
- s.files = ["CHANGELOG", "COPYING", "ec2onrails.gemspec", "echoe_config.rb", "examples/Capfile", "examples/deploy.rb", "examples/s3.yml", "lib/ec2onrails/capistrano_utils.rb", "lib/ec2onrails/recipes/db.rb", "lib/ec2onrails/recipes/deploy.rb", "lib/ec2onrails/recipes/server.rb", "lib/ec2onrails/recipes.rb", "lib/ec2onrails/version.rb", "lib/ec2onrails.rb", "Manifest", "Rakefile", "README.textile", "server/build", "server/files/etc/aliases", "server/files/etc/cron.d/ec2onrails", "server/files/etc/cron.daily/app", "server/files/etc/cron.daily/logrotate_post", "server/files/etc/cron.hourly/app", "server/files/etc/cron.monthly/app", "server/files/etc/cron.weekly/app", "server/files/etc/denyhosts.conf", "server/files/etc/dpkg/dpkg.cfg", "server/files/etc/ec2onrails/rails_env", "server/files/etc/ec2onrails/roles.yml", "server/files/etc/environment", "server/files/etc/event.d/god", "server/files/etc/god/db_primary.god", "server/files/etc/god/dkim_filter.god", "server/files/etc/god/examples/have_god_daemonize.god", "server/files/etc/god/master.conf", "server/files/etc/god/memcache.god", "server/files/etc/god/notifications.god", "server/files/etc/god/system.god", "server/files/etc/god/web.god", "server/files/etc/init.d/ec2-every-startup", "server/files/etc/init.d/ec2-first-startup", "server/files/etc/init.d/nginx", "server/files/etc/logrotate.d/mongrel", "server/files/etc/logrotate.d/nginx", "server/files/etc/memcached.conf", "server/files/etc/motd.tail", "server/files/etc/mysql/my.cnf", "server/files/etc/nginx/custom.conf", "server/files/etc/nginx/nginx.conf.erb", "server/files/etc/postfix/main.cf", "server/files/etc/README", "server/files/etc/ssh/sshd_config", "server/files/etc/sudoers", "server/files/etc/syslog.conf", "server/files/usr/local/ec2onrails/bin/archive_file", "server/files/usr/local/ec2onrails/bin/backup_app_db", "server/files/usr/local/ec2onrails/bin/backup_dir", "server/files/usr/local/ec2onrails/bin/ec2_meta_data", "server/files/usr/local/ec2onrails/bin/exec_runner", "server/files/usr/local/ec2onrails/bin/init_services", "server/files/usr/local/ec2onrails/bin/install_system_files", "server/files/usr/local/ec2onrails/bin/optimize_mysql", "server/files/usr/local/ec2onrails/bin/public-hostname", "server/files/usr/local/ec2onrails/bin/rails_env", "server/files/usr/local/ec2onrails/bin/rebundle", "server/files/usr/local/ec2onrails/bin/restore_app_db", "server/files/usr/local/ec2onrails/bin/set_rails_env", "server/files/usr/local/ec2onrails/bin/set_roles", "server/files/usr/local/ec2onrails/bin/uninstall_system_files", "server/files/usr/local/ec2onrails/config", "server/files/usr/local/ec2onrails/COPYING", "server/files/usr/local/ec2onrails/lib/aws_helper.rb", "server/files/usr/local/ec2onrails/lib/god_helper.rb", "server/files/usr/local/ec2onrails/lib/mysql_helper.rb", "server/files/usr/local/ec2onrails/lib/roles_helper.rb", "server/files/usr/local/ec2onrails/lib/s3_helper.rb", "server/files/usr/local/ec2onrails/lib/system_files_helper.rb", "server/files/usr/local/ec2onrails/lib/system_files_manifest.rb", "server/files/usr/local/ec2onrails/lib/utils.rb", "server/files/usr/local/ec2onrails/lib/vendor/ini.rb", "server/files/usr/local/ec2onrails/startup-scripts/every-startup/create-mysqld-pid-dir", "server/files/usr/local/ec2onrails/startup-scripts/every-startup/README", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/get-hostname", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/README", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions", "server/rakefile-wrapper", "server/rakefile.rb", "test/autobench.conf", "test/spec/lib/s3_helper_spec.rb", "test/spec/lib/s3_old.yml", "test/spec/lib/system_files_manifest_spec.rb", "test/spec/test_files/system_files1/_manifest", "test/spec/test_files/system_files1/test1", "test/spec/test_files/system_files1/test2", "test/spec/test_files/system_files1/testfolder/test3", "test/spec/test_files/system_files2/_manifest", "test/spec/test_files/system_files2/test1", "test/spec/test_files/system_files2/test2", "test/spec/test_files/system_files2/testfolder/test3", "test/spec/test_files/test2", "test/test_app/app/controllers/application_controller.rb", "test/test_app/app/controllers/db_fast_controller.rb", "test/test_app/app/controllers/fast_controller.rb", "test/test_app/app/controllers/slow_controller.rb", "test/test_app/app/controllers/very_slow_controller.rb", "test/test_app/app/helpers/application_helper.rb", "test/test_app/Capfile", "test/test_app/config/boot.rb", "test/test_app/config/database.yml", "test/test_app/config/deploy.rb", "test/test_app/config/ec2onrails/config.rb", "test/test_app/config/environment.rb", "test/test_app/config/environments/development.rb", "test/test_app/config/environments/production.rb", "test/test_app/config/environments/test.rb", "test/test_app/config/initializers/backtrace_silencers.rb", "test/test_app/config/initializers/inflections.rb", "test/test_app/config/initializers/mime_types.rb", "test/test_app/config/initializers/new_rails_defaults.rb", "test/test_app/config/initializers/session_store.rb", "test/test_app/config/locales/en.yml", "test/test_app/config/routes.rb", "test/test_app/doc/README_FOR_APP", "test/test_app/public/404.html", "test/test_app/public/422.html", "test/test_app/public/500.html", "test/test_app/public/favicon.ico", "test/test_app/public/images/rails.png", "test/test_app/public/index.html", "test/test_app/public/javascripts/application.js", "test/test_app/public/javascripts/controls.js", "test/test_app/public/javascripts/dragdrop.js", "test/test_app/public/javascripts/effects.js", "test/test_app/public/javascripts/prototype.js", "test/test_app/public/robots.txt", "test/test_app/Rakefile", "test/test_app/README", "test/test_app/script/about", "test/test_app/script/console", "test/test_app/script/dbconsole", "test/test_app/script/destroy", "test/test_app/script/generate", "test/test_app/script/performance/benchmarker", "test/test_app/script/performance/profiler", "test/test_app/script/plugin", "test/test_app/script/runner", "test/test_app/script/server", "test/test_app/test/performance/browsing_test.rb", "test/test_app/test/test_helper.rb", "TODO"]
17
- s.has_rdoc = true
16
+ s.files = ["CHANGELOG", "COPYING", "echoe_config.rb", "examples/Capfile", "examples/deploy.rb", "examples/s3.yml", "lib/ec2onrails/capistrano_utils.rb", "lib/ec2onrails/recipes/db.rb", "lib/ec2onrails/recipes/deploy.rb", "lib/ec2onrails/recipes/server.rb", "lib/ec2onrails/recipes.rb", "lib/ec2onrails/version.rb", "lib/ec2onrails.rb", "Manifest", "Rakefile", "README.textile", "server/build", "server/files/etc/aliases", "server/files/etc/cron.d/ec2onrails", "server/files/etc/cron.daily/app", "server/files/etc/cron.daily/logrotate_post", "server/files/etc/cron.hourly/app", "server/files/etc/cron.monthly/app", "server/files/etc/cron.weekly/app", "server/files/etc/default/varnish", "server/files/etc/default/varnishncsa", "server/files/etc/denyhosts.conf", "server/files/etc/dpkg/dpkg.cfg", "server/files/etc/ec2onrails/rails_env", "server/files/etc/ec2onrails/roles.yml", "server/files/etc/environment", "server/files/etc/event.d/god", "server/files/etc/god/db_primary.god", "server/files/etc/god/dkim_filter.god", "server/files/etc/god/examples/have_god_daemonize.god", "server/files/etc/god/master.conf", "server/files/etc/god/memcache.god", "server/files/etc/god/notifications.god", "server/files/etc/god/proxy.god", "server/files/etc/god/system.god", "server/files/etc/god/web.god", "server/files/etc/init.d/ec2-every-startup", "server/files/etc/init.d/ec2-first-startup", "server/files/etc/init.d/nginx", "server/files/etc/logrotate.d/mongrel", "server/files/etc/logrotate.d/nginx", "server/files/etc/memcached.conf", "server/files/etc/motd.tail", "server/files/etc/mysql/my.cnf", "server/files/etc/nginx/conf.d/custom.conf", "server/files/etc/nginx/nginx.conf.erb", "server/files/etc/postfix/main.cf", "server/files/etc/README", "server/files/etc/ssh/sshd_config", "server/files/etc/sudoers", "server/files/etc/syslog.conf", "server/files/etc/varnish/default.vcl.erb", "server/files/usr/local/ec2onrails/bin/archive_file", "server/files/usr/local/ec2onrails/bin/backup_app_db", "server/files/usr/local/ec2onrails/bin/backup_dir", "server/files/usr/local/ec2onrails/bin/ec2_meta_data", "server/files/usr/local/ec2onrails/bin/exec_runner", "server/files/usr/local/ec2onrails/bin/in_role", "server/files/usr/local/ec2onrails/bin/init_services", "server/files/usr/local/ec2onrails/bin/install_system_files", "server/files/usr/local/ec2onrails/bin/optimize_mysql", "server/files/usr/local/ec2onrails/bin/public-hostname", "server/files/usr/local/ec2onrails/bin/rails_env", "server/files/usr/local/ec2onrails/bin/rebundle", "server/files/usr/local/ec2onrails/bin/restore_app_db", "server/files/usr/local/ec2onrails/bin/set_rails_env", "server/files/usr/local/ec2onrails/bin/set_roles", "server/files/usr/local/ec2onrails/bin/uninstall_system_files", "server/files/usr/local/ec2onrails/config", "server/files/usr/local/ec2onrails/COPYING", "server/files/usr/local/ec2onrails/lib/aws_helper.rb", "server/files/usr/local/ec2onrails/lib/god_helper.rb", "server/files/usr/local/ec2onrails/lib/mysql_helper.rb", "server/files/usr/local/ec2onrails/lib/roles_helper.rb", "server/files/usr/local/ec2onrails/lib/s3_helper.rb", "server/files/usr/local/ec2onrails/lib/system_files_helper.rb", "server/files/usr/local/ec2onrails/lib/system_files_manifest.rb", "server/files/usr/local/ec2onrails/lib/utils.rb", "server/files/usr/local/ec2onrails/lib/vendor/ini.rb", "server/files/usr/local/ec2onrails/startup-scripts/every-startup/create-mysqld-pid-dir", "server/files/usr/local/ec2onrails/startup-scripts/every-startup/README", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/create-dirs", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/generate-default-web-cert-and-key", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/get-hostname", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/misc", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/prepare-mysql-data-dir", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/README", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-credentials", "server/files/usr/local/ec2onrails/startup-scripts/first-startup/setup-file-permissions", "server/rakefile-wrapper", "server/rakefile.rb", "test/autobench.conf", "test/spec/lib/s3_helper_spec.rb", "test/spec/lib/s3_old.yml", "test/spec/lib/system_files_manifest_spec.rb", "test/spec/test_files/system_files1/_manifest", "test/spec/test_files/system_files1/test1", "test/spec/test_files/system_files1/test2", "test/spec/test_files/system_files1/testfolder/test3", "test/spec/test_files/system_files2/_manifest", "test/spec/test_files/system_files2/test1", "test/spec/test_files/system_files2/test2", "test/spec/test_files/system_files2/testfolder/test3", "test/spec/test_files/test2", "test/test_app/app/controllers/application_controller.rb", "test/test_app/app/controllers/db_fast_controller.rb", "test/test_app/app/controllers/fast_controller.rb", "test/test_app/app/controllers/slow_controller.rb", "test/test_app/app/controllers/very_slow_controller.rb", "test/test_app/app/helpers/application_helper.rb", "test/test_app/Capfile", "test/test_app/config/boot.rb", "test/test_app/config/database.yml", "test/test_app/config/deploy.rb", "test/test_app/config/ec2onrails/config.rb", "test/test_app/config/environment.rb", "test/test_app/config/environments/development.rb", "test/test_app/config/environments/production.rb", "test/test_app/config/environments/test.rb", "test/test_app/config/initializers/backtrace_silencers.rb", "test/test_app/config/initializers/inflections.rb", "test/test_app/config/initializers/mime_types.rb", "test/test_app/config/initializers/new_rails_defaults.rb", "test/test_app/config/initializers/session_store.rb", "test/test_app/config/locales/en.yml", "test/test_app/config/routes.rb", "test/test_app/doc/README_FOR_APP", "test/test_app/public/404.html", "test/test_app/public/422.html", "test/test_app/public/500.html", "test/test_app/public/favicon.ico", "test/test_app/public/images/rails.png", "test/test_app/public/index.html", "test/test_app/public/javascripts/application.js", "test/test_app/public/javascripts/controls.js", "test/test_app/public/javascripts/dragdrop.js", "test/test_app/public/javascripts/effects.js", "test/test_app/public/javascripts/prototype.js", "test/test_app/public/robots.txt", "test/test_app/Rakefile", "test/test_app/README", "test/test_app/script/about", "test/test_app/script/console", "test/test_app/script/dbconsole", "test/test_app/script/destroy", "test/test_app/script/generate", "test/test_app/script/performance/benchmarker", "test/test_app/script/performance/profiler", "test/test_app/script/plugin", "test/test_app/script/runner", "test/test_app/script/server", "test/test_app/test/performance/browsing_test.rb", "test/test_app/test/test_helper.rb", "TODO", "ec2onrails.gemspec"]
18
17
  s.homepage = %q{http://ec2onrails.rubyforge.org}
19
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ec2onrails", "--main", "README.textile"]
20
19
  s.require_paths = ["lib"]
21
20
  s.rubyforge_project = %q{ec2onrails}
22
- s.rubygems_version = %q{1.3.2}
21
+ s.rubygems_version = %q{1.3.4}
23
22
  s.summary = %q{Client-side libraries (Capistrano tasks) for managing and deploying to EC2 on Rails servers.}
24
23
  s.test_files = ["test/test_app/test/performance/browsing_test.rb", "test/test_app/test/test_helper.rb"]
25
24
 
@@ -88,8 +88,8 @@ Capistrano::Configuration.instance.load do
88
88
  command because Net::SSH, which is used by Capistrano, needs it.
89
89
  This will only work if you have an ssh command in the path.
90
90
  If Capistrano can successfully connect to your EC2 instance you
91
- don't need to do this. It will copy from the first server in the
92
- :app role, this can be overridden by specifying the HOST
91
+ don't need to do this. It will copy from one of the servers
92
+ at random, this can be overridden by specifying the HOST
93
93
  environment variable
94
94
  DESC
95
95
  task :get_public_key_from_server do
@@ -52,7 +52,8 @@ Capistrano::Configuration.instance.load do
52
52
  on_rollback { drop }
53
53
  load_config
54
54
  start
55
- sleep(15) # make sure the db has some time to start up!
55
+ puts " * Pausing to give MySQL some time to start up..."
56
+ sleep 20
56
57
 
57
58
  run %{mysql -u root -e "drop database if exists test; flush privileges;"}
58
59
  # removing anonymous mysql accounts
@@ -1,5 +1,4 @@
1
1
  Capistrano::Configuration.instance(:must_exist).load do
2
- cfg = ec2onrails_config
3
2
 
4
3
  # Override default start/stop/restart tasks for Passenger
5
4
  namespace :deploy do
@@ -24,4 +23,4 @@ Capistrano::Configuration.instance(:must_exist).load do
24
23
  run "touch #{current_release}/tmp/restart.txt"
25
24
  end
26
25
  end
27
- end
26
+ end
@@ -0,0 +1,33 @@
1
+ # Configuration file for varnish
2
+ #
3
+ # /etc/init.d/varnish expects the variables $DAEMON_OPTS, $NFILES and $MEMLOCK
4
+ # to be set from this shell script fragment.
5
+ #
6
+
7
+ # Maximum number of open files (for ulimit -n)
8
+ NFILES=131072
9
+
10
+ # Maximum locked memory size (for ulimit -l)
11
+ # Used for locking the shared memory log in memory. If you increase log size,
12
+ # you need to increase this number as well
13
+ MEMLOCK=82000
14
+
15
+ # Default varnish instance name is the local nodename. Can be overridden with
16
+ # the -n switch, to have more instances on a single server.
17
+ INSTANCE=$(uname -n)
18
+
19
+
20
+ # Listen on port 80, administration on localhost:6082, and forward to
21
+ # one content server selected by the vcl file, based on the request.
22
+
23
+ # Use a 256 MB fixed-size cache file.
24
+ # TODO figure out how to configure this so that the varnishd process
25
+ # doesn't grow so large because we have little or no swap (or add
26
+ # more swap space)
27
+ #
28
+ # TODO pre-allocate the storage space using dd
29
+ #
30
+ DAEMON_OPTS="-a :80 \
31
+ -T localhost:6082 \
32
+ -f /etc/varnish/default.vcl \
33
+ -s file,/mnt/varnish/varnish_storage.bin,256M"
@@ -0,0 +1,11 @@
1
+ # Configuration file for varnishncsa
2
+ #
3
+ # Uncomment this to enable logging for varnish. Please make sure you have
4
+ # enough disk space for significant amounts of log data. To disable logging,
5
+ # set the variable to "0", "no", or leave it unset.
6
+ #
7
+ # NCSA log format, to be used by HTTP log analyzers
8
+ VARNISHNCSA_ENABLED=1
9
+
10
+ LOGFILE=/mnt/log/varnish/varnishncsa.log
11
+
@@ -2,3 +2,4 @@
2
2
  :memcache:
3
3
  :db_primary:
4
4
  :web:
5
+ :proxy:
@@ -3,10 +3,12 @@
3
3
  applog(nil, :info, "loading /etc/god/master.conf")
4
4
 
5
5
  require '/usr/local/ec2onrails/lib/god_helper'
6
+ require '/usr/local/ec2onrails/lib/roles_helper'
6
7
  require '/usr/local/ec2onrails/lib/utils'
7
8
  require "fileutils"
8
9
 
9
10
  include GodHelper
11
+ include Ec2onrails::RolesHelper
10
12
 
11
13
  APP_ROOT = "/mnt/app/current"
12
14
 
@@ -1,5 +1,5 @@
1
1
  God::Contacts::Email.message_settings = {
2
- :from => 'app@localhost'
2
+ :from => 'root@localhost'
3
3
  }
4
4
 
5
5
  God::Contacts::Email.server_settings = {
@@ -9,6 +9,6 @@ God::Contacts::Email.server_settings = {
9
9
 
10
10
  God.contact(:email) do |c|
11
11
  c.name = 'app'
12
- c.email = 'app@localhost'
12
+ c.email = 'root@localhost'
13
13
  c.group = 'default'
14
14
  end
@@ -0,0 +1,26 @@
1
+ God.watch do |w|
2
+ w.name = "varnish"
3
+ w.group = "proxy"
4
+ w.autostart = false
5
+
6
+ w.start = "/etc/init.d/varnish start"
7
+ w.stop = "/etc/init.d/varnish stop"
8
+ w.restart = "/etc/init.d/varnish restart"
9
+ w.pid_file = "/var/run/varnishd.pid"
10
+ w.grace = 10.seconds
11
+
12
+ default_configurations(w)
13
+
14
+ # I'm not sure if it's very useful to monitor the varnishd memory usage,
15
+ # because it writes the pid of the varnishd parent process in it's pid file,
16
+ # so I assume that's what god is monitoring, and the varnishd parent starts
17
+ # a child process to do the real work.
18
+ # Also, the child process allocates all cache storage with malloc, so the
19
+ # VSS size can get very large and depends on the amount of storage
20
+ # configured. It relies on the OS to page unused portions to disk, but at
21
+ # the moment we don't have much swap configured (just using the defaults
22
+ # from Eric Hammond's base image).
23
+ restart_if_resource_hog(w, :memory_usage => 100.megabytes, :cpu_usage => 50.percent)
24
+
25
+ monitor_lifecycle(w)
26
+ end
@@ -1,12 +1,11 @@
1
1
  God.watch do |w|
2
- server_status_path = '/'
3
2
  w.name = "nginx"
3
+ w.group = 'web'
4
+
4
5
  w.start = "/etc/init.d/nginx start"
5
6
  w.stop = "/etc/init.d/nginx stop"
6
7
  w.restart = "/etc/init.d/nginx restart"
7
8
  w.pid_file = "/var/run/nginx.pid"
8
- server_status_path = '/nginx_status'
9
- w.group = 'web'
10
9
  w.autostart = false
11
10
 
12
11
  default_configurations(w)
@@ -14,8 +13,8 @@ God.watch do |w|
14
13
  restart_if_resource_hog(w, :memory_usage => 250.megabytes) do |restart|
15
14
  restart.condition(:http_response_code) do |c|
16
15
  c.host = '127.0.0.1'
17
- c.port = 80
18
- c.path = server_status_path
16
+ c.port = in_role?(:proxy) ? 81 : 80
17
+ c.path = '/nginx_status'
19
18
  c.code_is_not = 200
20
19
  c.timeout = 5.seconds
21
20
  c.times = [3, 5] # 3 out of 5 intervals
@@ -23,4 +22,4 @@ God.watch do |w|
23
22
  end
24
23
 
25
24
  monitor_lifecycle(w)
26
- end
25
+ end
@@ -56,7 +56,7 @@ http {
56
56
  gzip_disable “MSIE [1-6].(?!.*SV1)”;
57
57
 
58
58
  server {
59
- listen 80;
59
+ listen <%= roles[:proxy] && roles[:proxy].include?("127.0.0.1") ? 81 : 80 %>;
60
60
  server_name _;
61
61
 
62
62
  # server-specific passenger settings
@@ -110,8 +110,7 @@ http {
110
110
  # page if it exists in the doc root. This is for capistrano's
111
111
  # disable web task
112
112
  if (-f $document_root/system/maintenance.html) {
113
- rewrite ^(.*)$ /system/maintenance.html last;
114
- break;
113
+ rewrite ^(.*)$ /system/maintenance.html break;
115
114
  }
116
115
 
117
116
  # see http://wiki.codemongers.com/NginxHttpStubStatusModule
@@ -125,7 +124,7 @@ http {
125
124
  deny all;
126
125
  }
127
126
 
128
- include /etc/nginx/custom.conf;
127
+ include /etc/nginx/conf.d/*.conf;
129
128
  }
130
129
 
131
130
  # This server is setup for ssl. Uncomment if
@@ -0,0 +1,140 @@
1
+ #This is the VCL configuration file for varnish. See the vcl(7)
2
+ #man page for details on VCL syntax and semantics.
3
+
4
+ # One backend for each instance in the "web" role. If that instance is also in
5
+ # the "proxy" role then it's listening on port 81, otherwise it's on port 80
6
+ <% roles[:web].each_with_index do |address, i| %>
7
+ backend web_<%= i %> {
8
+ .host = "<%= address %>";
9
+ .port = "<%= roles[:proxy] && roles[:proxy].include?(address) ? 81 : 80 %>";
10
+ }
11
+ <% end %>
12
+
13
+ <% unless config[:proxy] && config[:proxy][:caching_enabled] %>
14
+ # redefine the vcl_recv function to disable caching if
15
+ # config[:proxy][:caching_enabled] is not true for this instance.
16
+ sub vcl_recv {
17
+ if (req.request != "GET" &&
18
+ req.request != "HEAD" &&
19
+ req.request != "PUT" &&
20
+ req.request != "POST" &&
21
+ req.request != "TRACE" &&
22
+ req.request != "OPTIONS" &&
23
+ req.request != "DELETE") {
24
+ /* Non-RFC2616 or CONNECT which is weird. */
25
+ return (pipe);
26
+ }
27
+ return (pass);
28
+ }
29
+ <% end %>
30
+
31
+
32
+ #
33
+ #Below is a commented-out copy of the default VCL logic. If you
34
+ #redefine any of these subroutines, the built-in logic will be
35
+ #appended to your code.
36
+ #
37
+ #sub vcl_recv {
38
+ # if (req.request != "GET" &&
39
+ # req.request != "HEAD" &&
40
+ # req.request != "PUT" &&
41
+ # req.request != "POST" &&
42
+ # req.request != "TRACE" &&
43
+ # req.request != "OPTIONS" &&
44
+ # req.request != "DELETE") {
45
+ # /* Non-RFC2616 or CONNECT which is weird. */
46
+ # return (pipe);
47
+ # }
48
+ # if (req.request != "GET" && req.request != "HEAD") {
49
+ # /* We only deal with GET and HEAD by default */
50
+ # return (pass);
51
+ # }
52
+ # if (req.http.Authorization || req.http.Cookie) {
53
+ # /* Not cacheable by default */
54
+ # return (pass);
55
+ # }
56
+ # return (lookup);
57
+ #}
58
+ #
59
+ #sub vcl_pipe {
60
+ # return (pipe);
61
+ #}
62
+ #
63
+ #sub vcl_pass {
64
+ # return (pass);
65
+ #}
66
+ #
67
+ #sub vcl_hash {
68
+ # set req.hash += req.url;
69
+ # if (req.http.host) {
70
+ # set req.hash += req.http.host;
71
+ # } else {
72
+ # set req.hash += server.ip;
73
+ # }
74
+ # return (hash);
75
+ #}
76
+ #
77
+ #sub vcl_hit {
78
+ # if (!obj.cacheable) {
79
+ # return (pass);
80
+ # }
81
+ # return (deliver);
82
+ #}
83
+ #
84
+ #sub vcl_miss {
85
+ # return (fetch);
86
+ #}
87
+ #
88
+ #sub vcl_fetch {
89
+ # if (!obj.cacheable) {
90
+ # return (pass);
91
+ # }
92
+ # if (obj.http.Set-Cookie) {
93
+ # return (pass);
94
+ # }
95
+ # set obj.prefetch = -30s;
96
+ # return (deliver);
97
+ #}
98
+ #
99
+ #sub vcl_deliver {
100
+ # return (deliver);
101
+ #}
102
+ #
103
+ #sub vcl_discard {
104
+ # /* XXX: Do not redefine vcl_discard{}, it is not yet supported */
105
+ # return (discard);
106
+ #}
107
+ #
108
+ #sub vcl_prefetch {
109
+ # /* XXX: Do not redefine vcl_prefetch{}, it is not yet supported */
110
+ # return (fetch);
111
+ #}
112
+ #
113
+ #sub vcl_timeout {
114
+ # /* XXX: Do not redefine vcl_timeout{}, it is not yet supported */
115
+ # return (discard);
116
+ #}
117
+ #
118
+ #sub vcl_error {
119
+ # set obj.http.Content-Type = "text/html; charset=utf-8";
120
+ # synthetic {"
121
+ #<?xml version="1.0" encoding="utf-8"?>
122
+ #<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
123
+ # "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
124
+ #<html>
125
+ # <head>
126
+ # <title>"} obj.status " " obj.response {"</title>
127
+ # </head>
128
+ # <body>
129
+ # <h1>Error "} obj.status " " obj.response {"</h1>
130
+ # <p>"} obj.response {"</p>
131
+ # <h3>Guru Meditation:</h3>
132
+ # <p>XID: "} req.xid {"</p>
133
+ # <address>
134
+ # <a href="http://www.varnish-cache.org/">Varnish</a>
135
+ # </address>
136
+ # </body>
137
+ #</html>
138
+ #"};
139
+ # return (deliver);
140
+ #}
@@ -23,7 +23,7 @@
23
23
  # ex.
24
24
  # * exec_runner -role :db -exec 'echo "hello world"'
25
25
  # # will only run if the server is in the db role
26
- # * exec_runner -role :app -exec /some/app/specific/script/to/call
26
+ # * exec_runner -role :web -exec /some/app/specific/script/to/call
27
27
  #
28
28
 
29
29
  require "rubygems"
@@ -55,7 +55,7 @@ module CommandLineArgs extend OptiFlagSet
55
55
  and_process!
56
56
  end
57
57
 
58
- #strip out the ':', in case the user enters ':db', or ':app'
58
+ #strip out the ':', in case the user enters ':db', or ':web'
59
59
  if ARGV.flags.role && !in_role?(ARGV.flags.role.sub(/^:/, '').to_sym)
60
60
  puts "This script is not being run because the server is not running under the #{role} role" if ARGV.flags.v
61
61
  exit
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/ruby
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
+ require "#{File.dirname(__FILE__)}/../lib/roles_helper"
22
+ include Ec2onrails::RolesHelper
23
+
24
+ if ARGV[0].nil? || ARGV[0] == ""
25
+ puts "Missing rolename argument"
26
+ exit 2
27
+ end
28
+
29
+ if in_role?(ARGV[0].to_sym)
30
+ exit 0
31
+ else
32
+ exit 1
33
+ end
@@ -54,4 +54,3 @@ SYSTEM_FILES_SRC = "config/ec2onrails/system_files"
54
54
  app_dir = ARGV[0] || "/mnt/app/current"
55
55
 
56
56
  Ec2onrails::SystemFilesHelper.new.install_system_files(File.join(app_dir, SYSTEM_FILES_SRC))
57
-
@@ -49,16 +49,14 @@ FileUtils.copy(DEFAULT_CONFIG_LOC, "#{DEFAULT_CONFIG_LOC}.pre_optimized") unless
49
49
  num_cores = `cat /proc/cpuinfo`.find_all{|o| o =~ /^\s*processor\s+/}.size rescue 1
50
50
  #if also running app, just search for ruby because that will
51
51
  #include mongrel but also daemons and other scripts
52
- num_ruby_instances = local_roles.include?(:app) ? `ps ax | grep ruby | grep -v 'grep ruby'`.split("\n").size : 0
52
+ num_ruby_instances = local_roles.include?(:web) ? `ps ax | grep ruby | grep -v 'grep ruby'`.split("\n").size : 0
53
53
  avail_cores = num_cores - num_ruby_instances/4
54
54
  avail_cores = 0 if avail_cores.nil? || avail_cores < 0
55
55
 
56
56
 
57
57
  mem_opt = nil
58
- mem_opt ||= 0.15 if local_roles.include?(:app) && local_roles.include?(:web) && local_roles.include?(:memcache)
59
- mem_opt ||= 0.25 if local_roles.include?(:app) && local_roles.include?(:memcache)
60
- mem_opt ||= 0.35 if local_roles.include?(:app) || local_roles.include?(:memcache)
61
- mem_opt ||= 0.50 if local_roles.include?(:web)
58
+ mem_opt ||= 0.15 if local_roles.include?(:web) && local_roles.include?(:memcache)
59
+ mem_opt ||= 0.35 if local_roles.include?(:web) || local_roles.include?(:memcache)
62
60
  mem_opt ||= 0.70 #if only db, lets use a 70% ratio
63
61
 
64
62
  orig_free_mem = (`free -m` =~ /buffers\/cache:\s+\d+\s+(\d+)/; $1).to_i rescue 1024
@@ -17,14 +17,6 @@ module GodHelper
17
17
  end
18
18
  end
19
19
 
20
- # w.start_if do |start|
21
- # start.condition(:process_running) do |c|
22
- # c.interval = 5.seconds
23
- # c.running = false
24
- # c.notify = {:contacts => ['default'], :category => 'process exited...restarting'}
25
- # end
26
- # end
27
-
28
20
  # determine when process has finished starting
29
21
  # w.transition([:start, :restart], :up) do |on|
30
22
  # on.condition(:process_running) do |c|
@@ -70,7 +62,7 @@ module GodHelper
70
62
 
71
63
  end
72
64
  end
73
-
65
+
74
66
  def monitor_lifecycle(w)
75
67
  # w.transition(:up, :unmonitored) do |on|
76
68
  w.lifecycle do |on|
@@ -85,29 +77,6 @@ module GodHelper
85
77
  c.retry_within = 2.hours
86
78
  end
87
79
  end
88
- # w.lifecycle do |on|
89
- # on.condition(:flapping) do |c|
90
- # c.notify = {:contacts => ['default'], :category => 'process flapping...restarting'}
91
- # c.to_state = [:start, :restart]
92
- # c.times = 5
93
- # c.within = 60.seconds
94
- # c.retry_in = 10.minutes
95
- # c.retry_times = 5
96
- # c.retry_within = 2.hours
97
- # end
98
- # end
99
-
100
- # w.lifecycle do |on|
101
- # on.condition(:flapping) do |c|
102
- # c.to_state = [:start, :restart]
103
- # c.times = 5
104
- # c.within = 5.minutes
105
- # c.transition = :unmonitored
106
- # c.retry_in = 10.minutes
107
- # c.retry_times = 5
108
- # c.retry_within = 2.hours
109
- # end
110
- # end
111
80
  end
112
81
 
113
82
  class Configs
@@ -112,6 +112,8 @@ module Ec2onrails
112
112
  hosts_file = "/etc/hosts"
113
113
  FileUtils.cp "#{hosts_file}.original", hosts_file
114
114
  File.open(hosts_file, 'a') do |f|
115
+ f << "\n"
116
+ f << "# The following is automatically added by the EC2 on Rail set_roles script:\n"
115
117
  roles.each do |rolename, addresses|
116
118
  addresses.each_with_index do |address, i|
117
119
  f << "#{address} #{rolename.to_s.gsub(/_/, "-")}-#{i+1}\n"
@@ -135,6 +137,7 @@ module Ec2onrails
135
137
  # Set any variables that will be needed inside the templates
136
138
  # We're processing ALL templates, even ones that won't be used in the current role.
137
139
  rails_env = Ec2onrails::Utils.rails_env
140
+ config = Ec2onrails::Utils.load_config
138
141
  roles = self.roles
139
142
 
140
143
  Dir["/etc/**/*.erb"].each do |template|
@@ -12,5 +12,15 @@ module Ec2onrails
12
12
  def self.hostname
13
13
  `hostname -s`.strip
14
14
  end
15
+
16
+ def self.load_config
17
+ config = {}
18
+ begin
19
+ config = eval(File.read("/etc/ec2onrails/config.rb"))
20
+ rescue Exception => e
21
+ puts "ERROR:\n#{e.inspect}\n#{e.backtrace.join("\n")}"
22
+ end
23
+ return config
24
+ end
15
25
  end
16
- end
26
+ end
@@ -35,8 +35,11 @@ make_dir /etc/ec2onrails/system_files app:app
35
35
  make_dir /mnt/log
36
36
  make_dir /mnt/log/fsck
37
37
  make_dir /mnt/log/god
38
- make_dir /mnt/log/mysql mysql:mysql
39
- make_dir /mnt/log/nginx nginx:nginx
38
+ make_dir /mnt/log/mysql mysql:mysql
39
+ make_dir /mnt/log/nginx nginx:nginx
40
+ make_dir /mnt/log/varnish
41
+
42
+ make_dir /mnt/varnish/
40
43
 
41
44
  make_dir /mnt/tmp
42
45
  chmod 777 /mnt/tmp
data/server/rakefile.rb CHANGED
@@ -49,6 +49,8 @@ require "#{File.dirname(__FILE__)}/../lib/ec2onrails/version"
49
49
  libmysql-ruby
50
50
  libpcre3-dev
51
51
  libssl-dev
52
+ libxml2-dev
53
+ libxslt1-dev
52
54
  libyaml-ruby
53
55
  libzlib-ruby
54
56
  logrotate
@@ -67,6 +69,7 @@ require "#{File.dirname(__FILE__)}/../lib/ec2onrails/version"
67
69
  subversion
68
70
  sysstat
69
71
  unzip
72
+ varnish
70
73
  vim
71
74
  wget
72
75
  xfsprogs
@@ -159,7 +162,6 @@ task :install_nginx => [:require_root, :install_packages, :install_gems] do |t|
159
162
  # Make sure the dir is created but empty...lets start afresh
160
163
  run_chroot "mkdir -p -m 755 #{src_dir}/ && rm -rf #{src_dir}/*"
161
164
  run_chroot "sh -c 'cd #{src_dir} && wget -q #{nginx_img} && tar -xzf #{nginx_tar}'"
162
-
163
165
  run_chroot "sh -c 'cd #{src_dir}/#{nginx_version} && \
164
166
  ./configure \
165
167
  --sbin-path=/usr/sbin \
@@ -202,7 +204,7 @@ task :configure => [:require_root, :install_software] do |t|
202
204
  run_chroot "update-rc.d ec2-every-startup start 92 S ."
203
205
 
204
206
  # Disable the services that will be managed by god, depending on the roles
205
- %w(nginx mysql memcached).each do |service|
207
+ %w(nginx mysql memcached varnish).each do |service|
206
208
  run_chroot "update-rc.d -f #{service} remove"
207
209
  run_chroot "update-rc.d #{service} stop 20 2 3 4 5 ."
208
210
  end
@@ -212,6 +214,8 @@ task :configure => [:require_root, :install_software] do |t|
212
214
 
213
215
  # Create the mail aliases db
214
216
  run_chroot "postalias /etc/aliases"
217
+
218
+ run_chroot "chmod 0440 /etc/sudoers"
215
219
  end
216
220
  end
217
221
 
@@ -1,6 +1,6 @@
1
1
  set :application, "test_app"
2
2
 
3
- ssh_options[:keys] = [ENV['KEY'], "#{ENV['HOME']}/.ssh/ec2-key"]
3
+ ssh_options[:keys] = [ENV['KEY']]
4
4
 
5
5
  raise "please add HOST=ec2-xxx.xx... on the command line" unless ENV['HOST']
6
6
  set :host, ENV['HOST']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pauldowman-ec2onrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.10.0
4
+ version: 0.9.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Dowman, Adam Greene
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-06-29 00:00:00 -07:00
12
+ date: 2009-07-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,7 +71,6 @@ extra_rdoc_files:
71
71
  files:
72
72
  - CHANGELOG
73
73
  - COPYING
74
- - ec2onrails.gemspec
75
74
  - echoe_config.rb
76
75
  - examples/Capfile
77
76
  - examples/deploy.rb
@@ -94,6 +93,8 @@ files:
94
93
  - server/files/etc/cron.hourly/app
95
94
  - server/files/etc/cron.monthly/app
96
95
  - server/files/etc/cron.weekly/app
96
+ - server/files/etc/default/varnish
97
+ - server/files/etc/default/varnishncsa
97
98
  - server/files/etc/denyhosts.conf
98
99
  - server/files/etc/dpkg/dpkg.cfg
99
100
  - server/files/etc/ec2onrails/rails_env
@@ -106,6 +107,7 @@ files:
106
107
  - server/files/etc/god/master.conf
107
108
  - server/files/etc/god/memcache.god
108
109
  - server/files/etc/god/notifications.god
110
+ - server/files/etc/god/proxy.god
109
111
  - server/files/etc/god/system.god
110
112
  - server/files/etc/god/web.god
111
113
  - server/files/etc/init.d/ec2-every-startup
@@ -116,18 +118,20 @@ files:
116
118
  - server/files/etc/memcached.conf
117
119
  - server/files/etc/motd.tail
118
120
  - server/files/etc/mysql/my.cnf
119
- - server/files/etc/nginx/custom.conf
121
+ - server/files/etc/nginx/conf.d/custom.conf
120
122
  - server/files/etc/nginx/nginx.conf.erb
121
123
  - server/files/etc/postfix/main.cf
122
124
  - server/files/etc/README
123
125
  - server/files/etc/ssh/sshd_config
124
126
  - server/files/etc/sudoers
125
127
  - server/files/etc/syslog.conf
128
+ - server/files/etc/varnish/default.vcl.erb
126
129
  - server/files/usr/local/ec2onrails/bin/archive_file
127
130
  - server/files/usr/local/ec2onrails/bin/backup_app_db
128
131
  - server/files/usr/local/ec2onrails/bin/backup_dir
129
132
  - server/files/usr/local/ec2onrails/bin/ec2_meta_data
130
133
  - server/files/usr/local/ec2onrails/bin/exec_runner
134
+ - server/files/usr/local/ec2onrails/bin/in_role
131
135
  - server/files/usr/local/ec2onrails/bin/init_services
132
136
  - server/files/usr/local/ec2onrails/bin/install_system_files
133
137
  - server/files/usr/local/ec2onrails/bin/optimize_mysql
@@ -224,7 +228,8 @@ files:
224
228
  - test/test_app/test/performance/browsing_test.rb
225
229
  - test/test_app/test/test_helper.rb
226
230
  - TODO
227
- has_rdoc: true
231
+ - ec2onrails.gemspec
232
+ has_rdoc: false
228
233
  homepage: http://ec2onrails.rubyforge.org
229
234
  post_install_message:
230
235
  rdoc_options: