<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>server/files/etc/ec2onrails/rails_env</filename>
    </added>
    <added>
      <filename>server/files/etc/nginx/nginx.conf.erb</filename>
    </added>
    <added>
      <filename>server/files/etc/nginx/nginx.conf.working</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -14,7 +14,6 @@ ssh_options[:keys] = [&quot;#{ENV['HOME']}/.ssh/your-ec2-key&quot;]
 # 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,      &quot;ec2-12-xx-xx-xx.z-1.compute-1.amazonaws.com&quot;
-role :app,      &quot;ec2-34-xx-xx-xx.z-1.compute-1.amazonaws.com&quot;
 role :memcache, &quot;ec2-12-xx-xx-xx.z-1.compute-1.amazonaws.com&quot;
 role :db,       &quot;ec2-56-xx-xx-xx.z-1.compute-1.amazonaws.com&quot;, :primary =&gt; true
 # role :db,       &quot;ec2-56-xx-xx-xx.z-1.compute-1.amazonaws.com&quot;, :primary =&gt; true, :ebs_vol_id =&gt; 'vol-12345abc'</diff>
      <filename>examples/deploy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -48,11 +48,12 @@ Capistrano::Configuration.instance.load do
   set :use_sudo, false
   set :user, &quot;app&quot;
 
-  #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 &quot;deploy:cold&quot;, &quot;ec2onrails:setup&quot;
   
   after &quot;deploy:symlink&quot;, &quot;ec2onrails:server:set_roles&quot;, &quot;ec2onrails:server:init_services&quot;
   after &quot;deploy:cold&quot;, &quot;ec2onrails:db:init_backup&quot;, &quot;ec2onrails:db:optimize&quot;, &quot;ec2onrails:server:restrict_sudo_access&quot;
+  # TODO I don't think we can do gem source -a every time because I think it adds the same repo multiple times
   after &quot;ec2onrails:server:install_gems&quot;, &quot;ec2onrails:server:add_gem_sources&quot;
 
   # There's an ordering problem here. For convenience, we want to run 'rake gems:install' automatically
@@ -60,9 +61,10 @@ Capistrano::Configuration.instance.load do
   # 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 &quot;after&quot; 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 &quot;deploy:symlink&quot; or &quot;deploy:update&quot;
+  # The best solution is to use an after hook on &quot;deploy:symlink&quot; or &quot;deploy:update&quot; instead of on
+  # &quot;deploy:update_code&quot;
   on :load do
     before &quot;deploy:symlink&quot;, &quot;ec2onrails:server:run_rails_rake_gems_install&quot;
     before &quot;deploy:symlink&quot;, &quot;ec2onrails:server:install_system_files&quot;</diff>
      <filename>lib/ec2onrails/recipes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,27 +4,24 @@ Capistrano::Configuration.instance(:must_exist).load do
   # override default start/stop/restart tasks to use god
   namespace :deploy do
     desc &lt;&lt;-DESC
-      Overrides the default Capistrano deploy:start, uses \
-      'god start app'
+      Overrides the default Capistrano deploy:start.
     DESC
-    task :start, :roles =&gt; :app do
-      sudo &quot;god start app&quot;
+    task :start, :roles =&gt; :web do
+      run &quot;touch #{current_release}/tmp/restart.txt&quot;
     end
     
     desc &lt;&lt;-DESC
-      Overrides the default Capistrano deploy:stop, uses \
-      'god stop app'
+      Overrides the default Capistrano deploy:stop.
     DESC
-    task :stop, :roles =&gt; :app do
+    task :stop, :roles =&gt; :web do
       sudo &quot;god stop app&quot;
     end
     
     desc &lt;&lt;-DESC
-      Overrides the default Capistrano deploy:restart, uses \
-      'god restart app'
+      Overrides the default Capistrano deploy:restart.
     DESC
-    task :restart, :roles =&gt; :app do
-      sudo &quot;god restart app&quot;
+    task :restart, :roles =&gt; :web do
+      run &quot;touch #{current_release}/tmp/restart.txt&quot;
     end
   end
 end
\ No newline at end of file</diff>
      <filename>lib/ec2onrails/recipes/deploy.rb</filename>
    </modified>
    <modified>
      <diff>@@ -36,9 +36,8 @@ Capistrano::Configuration.instance(:must_exist).load do
       end
       
       desc &lt;&lt;-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 &quot;environment&quot;. 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</diff>
      <filename>lib/ec2onrails/recipes/server.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,5 +1,4 @@
 --- 
 :memcache: 
 :db_primary: 
-:app: 
 :web: </diff>
      <filename>server/files/etc/ec2onrails/roles.yml</filename>
    </modified>
    <modified>
      <diff>@@ -3,12 +3,13 @@
 applog(nil, :info, &quot;loading /etc/god/master.conf&quot;)
 
 require '/usr/local/ec2onrails/lib/god_helper'
+require '/usr/local/ec2onrails/lib/utils'
 require &quot;fileutils&quot;
 
 include GodHelper
 
 APP_ROOT = &quot;/mnt/app/current&quot;
-RAILS_ENV = `/usr/local/ec2onrails/bin/rails_env`.strip
+RAILS_ENV = Ec2onrails::Utils.rails_env
 
 
 @configs = GodHelper::Configs.new</diff>
      <filename>server/files/etc/god/master.conf</filename>
    </modified>
    <modified>
      <diff>@@ -19,11 +19,13 @@
 #    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 
 require &quot;#{File.dirname(__FILE__)}/../lib/roles_helper&quot;
+require &quot;#{File.dirname(__FILE__)}/../lib/utils&quot;
+
 include Ec2onrails::RolesHelper
 
 
 APP_ROOT = &quot;/mnt/app/current&quot;
-RAILS_ENV = `/usr/local/ec2onrails/bin/rails_env`.strip
+RAILS_ENV = Ec2onrails::Utils.rails_env
 
 #reload configs to pick up any new changes
 # Just a thought... do we really need to load god files from inside the app? They could just be installed via install_system_files, that would be simpler</diff>
      <filename>server/files/usr/local/ec2onrails/bin/init_services</filename>
    </modified>
    <modified>
      <diff>@@ -19,16 +19,15 @@
 #    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 
 
-# This script runs a command with RAILS_ENV set to the value that's specified
-# in the the mongrel_cluster config file. If a command isn't given as an 
-# argument it simply prints the value of RAILS_ENV
+# This script runs a command with RAILS_ENV set to current value for
+# this instance. If a command isn't given as an argument it simply
+# prints the value of RAILS_ENV
 
 require &quot;yaml&quot;
-
-@rails_env = YAML::load_file(&quot;/etc/mongrel_cluster/app.yml&quot;)[&quot;environment&quot;]
+require &quot;#{File.dirname(__FILE__)}/../lib/utils&quot;
 
 if ARGV.any?
-  exec &quot;env RAILS_ENV=#{@rails_env} #{ARGV.join(' ')}&quot;
+  exec &quot;env RAILS_ENV=#{Ec2onrails::Utils.rails_env} #{ARGV.join(' ')}&quot;
 else
-  puts @rails_env
+  puts Ec2onrails::Utils.rails_env
 end</diff>
      <filename>server/files/usr/local/ec2onrails/bin/rails_env</filename>
    </modified>
    <modified>
      <diff>@@ -19,8 +19,7 @@
 #    along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 
 
-# This script updates the value of &quot;environment&quot; in the the mongrel_cluster
-# config file.
+# This script updates the current RAILS_ENV setting for this instance
 
 require &quot;yaml&quot;
 require &quot;erb&quot;
@@ -32,9 +31,6 @@ end
 
 @rails_env = ARGV[0]
 
-# update mongrel_cluster config
-config = YAML::load_file(&quot;/etc/mongrel_cluster/app.yml&quot;)
-config[&quot;environment&quot;] = @rails_env
-File.open(&quot;/etc/mongrel_cluster/app.yml&quot;, 'w') do |f|
-  YAML.dump(config, f)
+File.open(&quot;/etc/ec2onrails/rails_env&quot;, 'w') do |f|
+  f &lt;&lt; @rails_env
 end</diff>
      <filename>server/files/usr/local/ec2onrails/bin/set_rails_env</filename>
    </modified>
    <modified>
      <diff>@@ -23,11 +23,12 @@ require 'pp'
 require 'resolv'
 require 'socket'
 require 'yaml'
+require &quot;#{File.dirname(__FILE__)}/utils&quot;
 
 module Ec2onrails
   module RolesHelper
+    
     ROLES_FILE = &quot;/etc/ec2onrails/roles.yml&quot;
-    MONGREL_CONF_FILE = &quot;/etc/mongrel_cluster/app.yml&quot;
 
     def local_address
       @local_address ||= get_metadata &quot;local-ipv4&quot;
@@ -100,38 +101,6 @@ module Ec2onrails
     #to provide deprecated usage
     alias :in_role :in_role?
     
-    def web_starting_port
-      mongrel_config['port'].to_i rescue 8000
-    end
-
-    def web_num_instances
-      mongrel_config['servers'].to_i rescue 6
-    end
-
-    def web_port_range
-      (web_starting_port..(web_starting_port + web_num_instances-1))
-    end
-    
-    def server_environment
-      mongrel_config[&quot;environment&quot;]
-    end
-    
-    def user
-      mongrel_config['user']
-    end
-
-    def group
-      mongrel_config['group']
-    end
-    
-    def application_root
-      mongrel_config['cwd']
-    end    
-    
-    def pid_file
-      &quot;#{application_root}/#{mongrel_config['pid_file']}&quot;
-    end
-
     # Re-write the roles file with the hostnames resolved
     def resolve_hostnames_in_roles_file
       File.open(ROLES_FILE, 'w') {|f| YAML.dump(roles, f)}
@@ -164,9 +133,8 @@ module Ec2onrails
     # The output from &quot;filename.erb&quot; will be saved as &quot;filename&quot;
     def process_config_file_templates
       # Set any variables that will be needed inside the templates
-      # We're processing ALL templates, even ones that won't be used in the current role, but I think that's OK.
-      web_port_range = self.web_port_range
-      web_starting_port = self.web_starting_port
+      # We're processing ALL templates, even ones that won't be used in the current role.
+      rails_env = Ec2onrails::Utils.rails_env
       roles = self.roles
 
       Dir[&quot;/etc/**/*.erb&quot;].each do |template|
@@ -181,11 +149,5 @@ module Ec2onrails
       end
     end
     
-    private
-
-    def mongrel_config
-      @mongrel_config ||= YAML::load_file(MONGREL_CONF_FILE)
-    end
-
   end
 end
\ No newline at end of file</diff>
      <filename>server/files/usr/local/ec2onrails/lib/roles_helper.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,7 @@ module Ec2onrails
     end
   
     def self.rails_env
-      `/usr/local/ec2onrails/bin/rails_env`.strip
+      File.read(&quot;/etc/ec2onrails/rails_env&quot;).strip
     end
     
     def self.hostname</diff>
      <filename>server/files/usr/local/ec2onrails/lib/utils.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,10 +26,6 @@ require 'yaml'
 require 'erb'
 require &quot;#{File.dirname(__FILE__)}/../lib/ec2onrails/version&quot;
 
-if `whoami`.strip != 'root'
-  raise &quot;Sorry, this buildfile must be run as root.&quot;
-end
-
 # package notes:
 # * gcc:            libraries needed to compile c/c++ files from source
 # * libmysqlclient-dev : provide mysqlclient-dev libs, needed for DataObject gems
@@ -86,9 +82,8 @@ end
   &quot;god&quot;,
   &quot;RubyInline&quot;,
   &quot;memcache-client&quot;,
-  &quot;mongrel&quot;,
-  &quot;mongrel_cluster&quot;,
   &quot;optiflag&quot;,
+  &quot;passenger&quot;,
   &quot;rails&quot;,
   &quot;rails -v '~&gt; 2.3.2'&quot;,
   &quot;rails -v '~&gt; 2.2.2'&quot;,
@@ -106,7 +101,7 @@ end
 task :default =&gt; :configure
 
 desc &quot;Removes all build files&quot;
-task :clean_all do |t|
+task :clean_all =&gt; :require_root do |t|
   puts &quot;Unmounting proc and dev from #{@build_root}...&quot;
   run &quot;umount #{@build_root}/ubuntu/proc&quot;, true
   run &quot;umount #{@build_root}/ubuntu/dev&quot;, true
@@ -115,8 +110,14 @@ task :clean_all do |t|
   rm_rf @build_root
 end
 
+task :require_root do |t|
+  if `whoami`.strip != 'root'
+    raise &quot;Sorry, this buildfile must be run as root.&quot;
+  end
+end
+
 desc &quot;Use aptitude to install required packages inside the image's filesystem&quot;
-task :install_packages do |t|
+task :install_packages =&gt; :require_root do |t|
   unless_completed(t) do
     ENV['DEBIAN_FRONTEND'] = 'noninteractive'
     ENV['LANG'] = ''
@@ -128,7 +129,7 @@ task :install_packages do |t|
 end
 
 desc &quot;Install required ruby gems inside the image's filesystem&quot;
-task :install_gems =&gt; [:install_packages] do |t|
+task :install_gems =&gt; [:require_root, :install_packages] do |t|
   unless_completed(t) do
     run_chroot &quot;sh -c 'cd /tmp &amp;&amp; wget -q http://rubyforge.org/frs/download.php/55066/rubygems-1.3.2.tgz &amp;&amp; tar zxf rubygems-1.3.2.tgz'&quot;
     run_chroot &quot;sh -c 'cd /tmp/rubygems-1.3.2 &amp;&amp; ruby setup.rb'&quot;
@@ -145,9 +146,9 @@ task :install_gems =&gt; [:install_packages] do |t|
 end
 
 desc &quot;Install nginx from source&quot;
-task :install_nginx =&gt; [:install_packages] do |t|
+task :install_nginx =&gt; [:require_root, :install_packages, :install_gems] do |t|
   unless_completed(t) do
-    nginx_version = &quot;nginx-0.6.35&quot;
+    nginx_version = &quot;nginx-0.6.36&quot;
     nginx_tar = &quot;#{nginx_version}.tar.gz&quot;
 
     nginx_img = &quot;http://sysoev.ru/nginx/#{nginx_tar}&quot;
@@ -155,35 +156,26 @@ task :install_nginx =&gt; [:install_packages] do |t|
     src_dir = &quot;/tmp/src/nginx&quot;
     # Make sure the dir is created but empty...lets start afresh
     run_chroot &quot;mkdir -p -m 755 #{src_dir}/ &amp;&amp;  rm -rf #{src_dir}/*&quot; 
-    run_chroot &quot;mkdir -p -m 755 #{src_dir}/modules/nginx-upstream-fair&quot;
     run_chroot &quot;sh -c 'cd #{src_dir} &amp;&amp; wget -q #{nginx_img} &amp;&amp; tar -xzf #{nginx_tar}'&quot;
-  
-    run_chroot &quot;sh -c 'cd #{src_dir}/modules &amp;&amp; \
-         wget -q #{fair_bal_img} &amp;&amp; \
-         tar -xzf *nginx-upstream-fair*.tar.gz -o -C ./nginx-upstream-fair &amp;&amp; \
-         mv nginx-upstream-fair/*/* nginx-upstream-fair/.'&quot;
-  
-    run_chroot &quot;sh -c 'cd #{src_dir}/#{nginx_version} &amp;&amp; \
-         ./configure \
-           --sbin-path=/usr/sbin \
-           --conf-path=/etc/nginx/nginx.conf \
-           --pid-path=/var/run/nginx.pid \
-           --with-http_ssl_module \
-           --with-http_stub_status_module \
-           --add-module=#{src_dir}/modules/nginx-upstream-fair &amp;&amp; \
-         make &amp;&amp; \
-         make install'&quot;
 
-    # run_chroot &quot;ln -sf /usr/local/nginx/sbin/nginx /usr/sbin/nginx&quot;
-    # run_chroot &quot;ln -sf /usr/local/nginx/conf /etc/nginx&quot;
+    run_chroot &quot;sh -c 'cd #{src_dir}/#{nginx_version} &amp;&amp; \
+       ./configure \
+         --sbin-path=/usr/sbin \
+         --conf-path=/etc/nginx/nginx.conf \
+         --pid-path=/var/run/nginx.pid \
+         --with-http_ssl_module \
+         --with-http_stub_status_module \
+         --add-module=`/usr/bin/passenger-config --root`/ext/nginx &amp;&amp; \
+       make &amp;&amp; \
+       make install'&quot;
   end
 end
 
 desc &quot;Install Ubuntu packages, download and compile other software, and install gems&quot;
-task :install_software =&gt; [:install_gems, :install_packages, :install_nginx]
+task :install_software =&gt; [:require_root, :install_gems, :install_packages, :install_nginx]
 
 desc &quot;Configure the image&quot;
-task :configure =&gt; [:install_software] do |t|
+task :configure =&gt; [:require_root, :install_software] do |t|
   unless_completed(t) do
     sh(&quot;cp -r files/* #{@fs_dir}&quot;)
     replace(&quot;#{@fs_dir}/etc/motd.tail&quot;, /!!VERSION!!/, &quot;Version #{@version}&quot;)</diff>
      <filename>server/rakefile.rb</filename>
    </modified>
    <modified>
      <diff>@@ -6,7 +6,6 @@ ssh_options[:keys] = [&quot;#{ENV['HOME']}/.ssh/public-ec2-key&quot;]
 
 set :host, ENV['HOST'] || &quot;&quot;
 role :web, host
-role :app, host
 role :db,  host, :primary =&gt; true
 
 set :rails_env, &quot;production&quot;</diff>
      <filename>test/test_app/config/deploy.rb</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>ec2onrails.gemspec</filename>
    </removed>
    <removed>
      <filename>server/files/etc/god/app.god</filename>
    </removed>
    <removed>
      <filename>server/files/etc/mongrel_cluster/app.yml</filename>
    </removed>
    <removed>
      <filename>server/files/etc/nginx/nginx.conf</filename>
    </removed>
    <removed>
      <filename>server/files/etc/nginx/upstream_members.erb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>fb89a916b1888b7ab345d2f00d95f6f556589b90</id>
    </parent>
  </parents>
  <author>
    <name>Paul Dowman</name>
    <email>paul@pauldowman.com</email>
  </author>
  <url>http://github.com/pauldowman/ec2onrails/commit/36fd82ec1a609d9947aacd9142571f4d9a2497a3</url>
  <id>36fd82ec1a609d9947aacd9142571f4d9a2497a3</id>
  <committed-date>2009-04-30T06:32:17-07:00</committed-date>
  <authored-date>2009-04-30T06:32:17-07:00</authored-date>
  <message>First pass at switching from mongrel to Passenger. Not yet fully tested. The app role has been removed because passenger runs in the web role, a proxy role will be added to handle multi-instance setups.</message>
  <tree>38ac3fca4988d16d2ba428250106837f5dbb5fc7</tree>
  <committer>
    <name>Paul Dowman</name>
    <email>paul@pauldowman.com</email>
  </committer>
</commit>
