<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: mongrel code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Sun, 18 May 2008 00:19:36 GMT</pubDate>
    <description>DZone Snippets: mongrel code</description>
    <item>
      <title>Mongrel and Apache fun with Capistrano 2.0</title>
      <link>http://snippets.dzone.com/posts/show/4510</link>
      <description>I got the Mongrel recipes from somewhere else -- I sadly don't remember where -- and modified them a bit.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;namespace :deploy do&lt;br /&gt;  namespace :mongrel do&lt;br /&gt;    [ :stop, :start, :restart ].each do |t|&lt;br /&gt;      desc "#{t.to_s.capitalize} the mongrel appserver"&lt;br /&gt;      task t, :roles =&gt; :app do&lt;br /&gt;        run "mongrel_rails cluster::#{t.to_s} --clean -C #{mongrel_conf}"&lt;br /&gt;      end&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;  &lt;br /&gt;  namespace :apache do&lt;br /&gt;    desc "Start Apache"&lt;br /&gt;    task :start, :roles =&gt; :web do&lt;br /&gt;      sudo "/etc/init.d/httpd start &gt; /dev/null"&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    desc "Stop Apache"&lt;br /&gt;    task :stop, :roles =&gt; :web do&lt;br /&gt;      sudo "/etc/init.d/httpd stop &gt; /dev/null"&lt;br /&gt;    end&lt;br /&gt;&lt;br /&gt;    desc "Restart Apache"&lt;br /&gt;    task :restart, :roles =&gt; :web do&lt;br /&gt;      sudo "/etc/init.d/httpd restart &gt; /dev/null"&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  desc "Custom restart task for mongrel cluster"&lt;br /&gt;  task :restart do&lt;br /&gt;    deploy.mongrel.restart&lt;br /&gt;    deploy.apache.restart&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  desc "Custom start task for mongrel cluster"&lt;br /&gt;  task :start, :roles =&gt; :app do&lt;br /&gt;    deploy.mongrel.start&lt;br /&gt;    deploy.apache.start&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  desc "Custom stop task for mongrel cluster"&lt;br /&gt;  task :stop, :roles =&gt; :app do&lt;br /&gt;    deploy.apache.stop&lt;br /&gt;    deploy.mongrel.stop&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;end&lt;/code&gt;</description>
      <pubDate>Fri, 07 Sep 2007 16:31:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/4510</guid>
      <author>hmans (Hendrik Mans)</author>
    </item>
    <item>
      <title>Mongrel Startup Script</title>
      <link>http://snippets.dzone.com/posts/show/2594</link>
      <description>I couldn't find one that did exactly what I wanted, so I cooked up this ruby script. Be sure to change app_dir and apps near the top to match your environment. On my ubuntu/debian server, this script resides in /etc/init.d. I ran "sudo update-rc.d -f mongrel defaults" to make it run on startup.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#!/usr/bin/env ruby&lt;br /&gt;#&lt;br /&gt;# mongrel       Startup script for Mongrel by Tim Morgan&lt;br /&gt;#&lt;br /&gt;# chkconfig: - 85 15&lt;br /&gt;# description: mongrel manages Mongrel&lt;br /&gt;#&lt;br /&gt;&lt;br /&gt;app_dir = '/var/rails'&lt;br /&gt;&lt;br /&gt;apps = {&lt;br /&gt;  'hpy' =&gt; 8001,&lt;br /&gt;  '43verses' =&gt; 8002&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;if ['stop', 'restart'].include? ARGV.first&lt;br /&gt;  apps.each do |path, port|&lt;br /&gt;    path = File.join app_dir, path&lt;br /&gt;    puts "Stopping #{path}..."&lt;br /&gt;    `mongrel_rails stop -c #{path} -P log/mongrel.pid`&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;if ['start', 'restart'].include? ARGV.first&lt;br /&gt;  apps.each do |path, port|&lt;br /&gt;    path = File.join app_dir, path&lt;br /&gt;    puts "Starting #{path} on #{port}..."&lt;br /&gt;    `mongrel_rails start -d -p #{port} -e production -c #{path} -P log/mongrel.pid`&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;unless ['start', 'stop', 'restart'].include? ARGV.first&lt;br /&gt;    puts "Usage: mongrel {start|stop|restart}"&lt;br /&gt;    exit&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Thu, 14 Sep 2006 18:42:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2594</guid>
      <author>timmorgan (Tim Morgan)</author>
    </item>
    <item>
      <title>Exempt directories from Apache's ProxyPass directive</title>
      <link>http://snippets.dzone.com/posts/show/2433</link>
      <description>Very useful if forwarding to Mongrel, etc.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;        ProxyPass /stylesheets !&lt;br /&gt;        ProxyPass /javascripts !&lt;br /&gt;        ProxyPass /images !     &lt;br /&gt;        ProxyPass / http://127.0.0.1:3010/&lt;br /&gt;        ProxyPassReverse / http://127.0.0.1:3010/  &lt;/code&gt;</description>
      <pubDate>Thu, 17 Aug 2006 05:25:50 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2433</guid>
      <author>jswizard (JavaScript Wizard)</author>
    </item>
    <item>
      <title>Mongrel Spinner and Restart tasks for Capistrano</title>
      <link>http://snippets.dzone.com/posts/show/2057</link>
      <description>These tasks should work with the default deploy.rb file. I assume you've at least read the Capistrano manual at rubyonrails.com, also, you should get your app running on mongrel first with manual booting and restarting before you try to automate.&lt;br /&gt;&lt;br /&gt;h2. Spinner&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;desc &lt;&lt;-DESC&lt;br /&gt;Spinner is run by the default cold_deploy task. Instead of using script/spinner, we're just gonna rely on Mongrel to keep itself up.&lt;br /&gt;DESC&lt;br /&gt;task :spinner, :roles =&gt; :app do&lt;br /&gt;  application_port = xxxx #get this from your friendly sysadmin&lt;br /&gt;  run "mongrel_rails start -e production -p #{application_port} -d -c #{current_path}"&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;h2. Restart&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;desc "Restart the web server"&lt;br /&gt;task :restart, :roles =&gt; :app do&lt;br /&gt;  begin&lt;br /&gt;    run "cd #{current_path} &amp;&amp; mongrel_rails restart"&lt;br /&gt;  rescue RuntimeError =&gt; e&lt;br /&gt;    puts e&lt;br /&gt;    puts "Probably not a big deal, so I'll just keep trucking..."&lt;br /&gt;  end&lt;br /&gt;end&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;There's a more complete article &lt;a href="http://jchris.mfdz.com/articles/2006/05/09/deploying-with-capistrano-and-mongrel-on-planet-argon"&gt;on my blog.&lt;/a&gt;</description>
      <pubDate>Wed, 17 May 2006 10:18:22 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2057</guid>
      <author>jchris (Chris Anderson)</author>
    </item>
    <item>
      <title>Mongrel on Win32 as Service</title>
      <link>http://snippets.dzone.com/posts/show/1846</link>
      <description>Mongrel now has support for running as a Win32 service right out of the box. The support is still rough but works well enough that we decided to release it. You can thank Luis Lavena for working on this and making it so nice.&lt;br /&gt;&lt;br /&gt;After you do the gem install, find a Rails application you want to run and do:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ mongrel_rails_service install -n myapp -r c:\my\path\to\myapp -p 4000 -e production&lt;br /&gt;$ mongrel_rails_service start -n myapp&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Now hit the port and poof, works. Stopping the app is just done with:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ mongrel_rails_service stop -n myapp&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;And, you can even set the CPU processor affinity for the service when yourun the install command. Can&#8217;t even do that on POSIX yet. Now that&#8217;s hot.&lt;br /&gt;&lt;br /&gt;If you run into an app that&#8217;s not running right, my suggestion is to run it with the regular mongrel_rails runner:&lt;br /&gt;&lt;code&gt;&lt;br /&gt;$ cd c:\my\path\to\myapp&lt;br /&gt;$ mongrel_rails start -p 4500&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;Since that will spit out error messages and stuff to the console. Use CTRL-Pause/Break to stop.&lt;br /&gt;</description>
      <pubDate>Wed, 05 Apr 2006 09:44:32 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/1846</guid>
      <author>MattScilipoti (Matt Scilipoti)</author>
    </item>
  </channel>
</rss>
