Permalink
Browse files

First pass at switching from mongrel to Passenger. Not yet fully test…

…ed. The app role has been removed because passenger runs in the web role, a proxy role will be added to handle multi-instance setups.
  • Loading branch information...
1 parent fb89a91 commit 36fd82ec1a609d9947aacd9142571f4d9a2497a3 @pauldowman committed Apr 30, 2009
View
@@ -1,47 +0,0 @@
-# This file is auto-generated, do not edit.
-# Edit echoe_config.rb and then run 'rake ec2onrails_gem'
-#
-# -*- encoding: utf-8 -*-
-
-Gem::Specification.new do |s|
- s.name = %q{ec2onrails}
- s.version = "0.9.10"
-
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
- s.authors = ["Paul Dowman, Adam Greene"]
- s.date = %q{2009-04-06}
- s.description = %q{Client-side libraries (Capistrano tasks) for managing and deploying to EC2 on Rails servers.}
- s.email = %q{paul@pauldowman.com}
- 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"]
- 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/README", "server/files/etc/ec2onrails/roles.yml", "server/files/etc/environment", "server/files/etc/event.d/god", "server/files/etc/god/app.god", "server/files/etc/god/db.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/mongrel_cluster/app.yml", "server/files/etc/motd.tail", "server/files/etc/mysql/my.cnf", "server/files/etc/nginx/custom.conf", "server/files/etc/nginx/nginx.conf", "server/files/etc/nginx/upstream_members.erb", "server/files/etc/postfix/main.cf", "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/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/fix-var-run-permissions", "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", "server/README", "setup.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.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/app/helpers/db_fast_helper.rb", "test/test_app/app/helpers/fast_helper.rb", "test/test_app/app/helpers/slow_helper.rb", "test/test_app/app/helpers/very_slow_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/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/routes.rb", "test/test_app/db/schema.rb", "test/test_app/doc/README_FOR_APP", "test/test_app/public/404.html", "test/test_app/public/500.html", "test/test_app/public/dispatch.cgi", "test/test_app/public/dispatch.fcgi", "test/test_app/public/dispatch.rb", "test/test_app/public/favicon.ico", "test/test_app/public/images/rails.png", "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/breakpointer", "test/test_app/script/console", "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/performance/request", "test/test_app/script/plugin", "test/test_app/script/process/inspector", "test/test_app/script/process/reaper", "test/test_app/script/process/spawner", "test/test_app/script/runner", "test/test_app/script/server", "test/test_app/test/functional/db_fast_controller_test.rb", "test/test_app/test/functional/fast_controller_test.rb", "test/test_app/test/functional/slow_controller_test.rb", "test/test_app/test/functional/very_slow_controller_test.rb", "test/test_app/test/test_helper.rb", "test/test_ec2onrails.rb", "test/test_helper.rb", "TODO"]
- s.has_rdoc = true
- s.homepage = %q{http://ec2onrails.rubyforge.org}
- s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ec2onrails", "--main", "README.textile"]
- s.require_paths = ["lib"]
- s.rubyforge_project = %q{ec2onrails}
- s.rubygems_version = %q{1.3.1}
- s.summary = %q{Client-side libraries (Capistrano tasks) for managing and deploying to EC2 on Rails servers.}
- s.test_files = ["test/test_app/test/functional/db_fast_controller_test.rb", "test/test_app/test/functional/fast_controller_test.rb", "test/test_app/test/functional/slow_controller_test.rb", "test/test_app/test/functional/very_slow_controller_test.rb", "test/test_app/test/test_helper.rb", "test/test_ec2onrails.rb", "test/test_helper.rb"]
-
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 2
-
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<capistrano>, [">= 2.4.3"])
- s.add_runtime_dependency(%q<archive-tar-minitar>, [">= 0.5.2"])
- s.add_runtime_dependency(%q<optiflag>, [">= 0.6.5"])
- s.add_development_dependency(%q<rake>, [">= 0.7.1"])
- else
- s.add_dependency(%q<capistrano>, [">= 2.4.3"])
- s.add_dependency(%q<archive-tar-minitar>, [">= 0.5.2"])
- s.add_dependency(%q<optiflag>, [">= 0.6.5"])
- s.add_dependency(%q<rake>, [">= 0.7.1"])
- end
- else
- s.add_dependency(%q<capistrano>, [">= 2.4.3"])
- s.add_dependency(%q<archive-tar-minitar>, [">= 0.5.2"])
- s.add_dependency(%q<optiflag>, [">= 0.6.5"])
- s.add_dependency(%q<rake>, [">= 0.7.1"])
- end
-end
View
@@ -14,7 +14,6 @@
# any other name (in case you have your own DNS alias) or it won't
# be able to resolve to the internal IP address.
role :web, "ec2-12-xx-xx-xx.z-1.compute-1.amazonaws.com"
-role :app, "ec2-34-xx-xx-xx.z-1.compute-1.amazonaws.com"
role :memcache, "ec2-12-xx-xx-xx.z-1.compute-1.amazonaws.com"
role :db, "ec2-56-xx-xx-xx.z-1.compute-1.amazonaws.com", :primary => true
# role :db, "ec2-56-xx-xx-xx.z-1.compute-1.amazonaws.com", :primary => true, :ebs_vol_id => 'vol-12345abc'
@@ -48,21 +48,23 @@
set :use_sudo, false
set :user, "app"
- #in case any changes were made to the configs, like changing the number of mongrels
+ #in case any changes were made to the configs
before "deploy:cold", "ec2onrails:setup"
after "deploy:symlink", "ec2onrails:server:set_roles", "ec2onrails:server:init_services"
after "deploy:cold", "ec2onrails:db:init_backup", "ec2onrails:db:optimize", "ec2onrails:server:restrict_sudo_access"
+ # TODO I don't think we can do gem source -a every time because I think it adds the same repo multiple times
after "ec2onrails:server:install_gems", "ec2onrails:server:add_gem_sources"
# There's an ordering problem here. For convenience, we want to run 'rake gems:install' automatically
# on every deploy, but in the ec2onrails:setup task I want to do update_code before any other
# setup tasks, and at that point I don't want run_rails_rake_gems_install to run. So run_rails_rake_gems_install
# can't be triggered by an "after" hook on update_code.
# But users might want to have their own tasks triggered after update_code, and those tasks will
- # need to have the gems installed already.
+ # fail if they require gems to be installed (or anything else to be set up).
#
- # The best solution is to use an after hook on "deploy:symlink" or "deploy:update"
+ # The best solution is to use an after hook on "deploy:symlink" or "deploy:update" instead of on
+ # "deploy:update_code"
on :load do
before "deploy:symlink", "ec2onrails:server:run_rails_rake_gems_install"
before "deploy:symlink", "ec2onrails:server:install_system_files"
@@ -4,27 +4,24 @@
# override default start/stop/restart tasks to use god
namespace :deploy do
desc <<-DESC
- Overrides the default Capistrano deploy:start, uses \
- 'god start app'
+ Overrides the default Capistrano deploy:start.
DESC
- task :start, :roles => :app do
- sudo "god start app"
+ task :start, :roles => :web do
+ run "touch #{current_release}/tmp/restart.txt"
end
desc <<-DESC
- Overrides the default Capistrano deploy:stop, uses \
- 'god stop app'
+ Overrides the default Capistrano deploy:stop.
DESC
- task :stop, :roles => :app do
+ task :stop, :roles => :web do
sudo "god stop app"
end
desc <<-DESC
- Overrides the default Capistrano deploy:restart, uses \
- 'god restart app'
+ Overrides the default Capistrano deploy:restart.
DESC
- task :restart, :roles => :app do
- sudo "god restart app"
+ task :restart, :roles => :web do
+ run "touch #{current_release}/tmp/restart.txt"
end
end
end
@@ -36,9 +36,8 @@
end
desc <<-DESC
- Change the default value of RAILS_ENV on the server. Technically
- this changes the server's mongrel config to use a different value
- for "environment". The value is specified in :rails_env.
+ Change the default value of RAILS_ENV on the server.
+ The value is specified in :rails_env.
Be sure to do deploy:restart after this.
DESC
task :set_rails_env do
@@ -0,0 +1 @@
+production
@@ -1,5 +1,4 @@
---
:memcache:
:db_primary:
-:app:
:web:
@@ -1,39 +0,0 @@
-# rolling restart idea plagiarized directly from:
-# http://blog.pragmatic-it.de/articles/2008/07/09/poor-mans-rolling-restart-for-thin-god
-#NOTE: this doesn't do what you think it does...
-# requests are queued up at nginx and requests start to time out
-restart_time = 2.seconds #how long to restart the entire cluster
-rolling_delay = (restart_time / @configs.web_num_instances.to_f).ceil
-@configs.web_port_range.each_with_index do |port, i|
- God.watch do |w|
- w.name = "mongrel_#{port}"
- w.group = 'app'
- w.uid = @configs.user
- w.gid = @configs.group
- w.autostart = false
-
- w.start = "mongrel_rails cluster::start -C /etc/mongrel_cluster/app.yml --clean --only #{port}"
- w.stop = "mongrel_rails cluster::stop -C /etc/mongrel_cluster/app.yml --clean --only #{port}"
- w.restart = "sleep #{i*rolling_delay}; mongrel_rails cluster::restart -C /etc/mongrel_cluster/app.yml --clean --only #{port}"
-
- w.pid_file = "/mnt/app/shared/log/mongrel.#{port}.pid"
- w.grace = 60.seconds
-
- default_configurations(w)
- restart_if_resource_hog(w, :memory_usage => 170.megabytes) do |restart|
- #NOTE: this will hit every instance, meaning every minute you have a hit for every port you have a mongrel on.
- # adding the port number to the call just to help with making this obvious in the logs
- restart.condition(:http_response_code) do |c|
- c.code_is_not = %w(200 304)
- c.host = '127.0.0.1'
- c.path = "/?port=#{port}"
- c.port = port
- c.timeout = 10.seconds
- c.times = 2
- c.interval = 1.minute
- end
- end
-
- monitor_lifecycle(w)
- end
-end
@@ -3,12 +3,13 @@
applog(nil, :info, "loading /etc/god/master.conf")
require '/usr/local/ec2onrails/lib/god_helper'
+require '/usr/local/ec2onrails/lib/utils'
require "fileutils"
include GodHelper
APP_ROOT = "/mnt/app/current"
-RAILS_ENV = `/usr/local/ec2onrails/bin/rails_env`.strip
+RAILS_ENV = Ec2onrails::Utils.rails_env
@configs = GodHelper::Configs.new
@@ -1,9 +0,0 @@
----
-cwd: /mnt/app/current
-port: "8000"
-environment: production
-pid_file: log/mongrel.pid
-servers: 6
-daemon: true
-user: app
-group: app
Oops, something went wrong.

0 comments on commit 36fd82e

Please sign in to comment.