railsmachine 1.0.3

Posted by bradley on December 18 2008 at 02:35 PM | 2 comments

Today we pushed out the latest version of the railsmachine gem. This release contains a few bug fixes plus support for Git and Phusion Passenger. The new gem is available on RubyForge and installable with gem update railsmachine. The code is also available for browsing/forking on github.

Before trying out the gem, you’ll need to make sure that your Rails Machine is setup with the new packages. The wiki has instructions for installing Git and installing and using Passenger including Ruby Enterprise Edition.

Once your server is setup, the groovy app:switch task will let you toggle between Mongrel and Passenger. A walkthrough is available on the PhusionPassenger page. For new deployments, we’ve updated the 5 minute guide to support Git and Passenger.

I highly recommend not trying this on your production applications without a little testing. We can easily clone a staging server to help avoid any unanticipated issues (and downtime). Also, consider that if your app is running fine, don’t switch just for fun. If you have any issues or questions, please submit a request.

Certainly I have some nostalgia for the mod_proxy_balancer and mongrel_cluster approach since 1,000s of Rails applications have been deployed successfully using it. However, that was 2 1/2 years ago and Passenger is clearly the right direction. I’m behind it 100% and we’re working on some new tools that will make deployment a cinch on one or hundred servers. Stay tuned for more deployment news after the holidays.

[ANN] Machinify: Stack Toolkit

Posted by bradley on May 25 2007 at 01:45 AM | 3 comments

After RailsConf, DHH announced a new mailing list for Rails stacks. After watching a day of posts, I decided to force myself to finally implement some ideas for a simple, dependency-driven toolkit for assembling and installing stacks based on Rake. I hope this gem can grow to support a variety of packages, stacks, and operating systems.

Over the past year, the Rails Machine stack has been deployed on over 400 virtual servers for our hosting customers and a number of customers of our commercial support offerings. I don’t know exactly how many Rails applications this is, but 1000ish would be a reasonable guess. Starting with this gem and a series of releases to follow, I would like to see the stack have a life outside of our firewalls!

This first release lays the foundation for building stacks with different components and different platforms with a common interface. For this release, I’ve provided foundational tasks for installing Apache 2.2, Mongrel, mongrel_cluster, Rails, and MySQL on Ubuntu Feisty Fawn.

To get up and running, execute the following:

sudo aptitude install -y ruby rubygems
sudo gem update --system
sudo gem install rake machinify
machinify .
rake stack:install


If you need RMagick, you can run rake imagemagick:install. There are a number of tasks available for installing a single package, server role (web, app, db), and basic service management commands. Tasks include:

rake apache:install               # Installs apache with worker mpm
rake apache:restart               # Restarts the apache process
rake imagemagick:install          # Installs ImageMagick and RMagick
rake mongrel:cluster:install      # Installs scripts for managing mongrel clusters
rake mysql:client:install         # Install mysql client and library
rake mysql:server:install         # Install mysql and ruby library
rake mysql:server:restart         # Restarts the mysql process
rake rails:install                # Installs rails
rake stack:install                # Installs a full web application stack
rake svn:install                  # Installs Subversion revision control system


In addition, there are package independent tasks that will be configurable in an upcoming release:

rake web:install                  # Installs web server stack
rake web:restart                  # Restarts the web server process
rake db:client:install            # Installs database client stack
rake db:server:install            # Installs database server stack


Run rake -T to see the full list. You can also create your own stacks with custom tasks.

Some may wonder why I didn’t write this using Capistrano like other deployment gems. Personally, I feel that Capistrano is a user interface to ssh. It is the “view” in MVC. It is an excellent system for invoking commands over SSH and an amazing piece of code. However, it is very easy to try to solve every problem using it including but not limited to automated deployment, stack installation, virtual machine creation, and global warming. If cap is the view, then rake on the server is the controller. Think of tasks like Rails actions. By refactoring the code to the server, you can create APIs over SSH. This approach allows a single cap recipe to execute commands on servers with different operating systems and stacks installed. A cap task that calls “rake stack:install” can be completely ignorant of the details of the server. For example, cap web:restart could call rake web:restart and not care if the server was running Apache, Nginx, Linux, or OpenSolaris. Expect updates to the railsmachine gem to reflect this approach.

Some may also wonder why Ubuntu. I’ve used Ubuntu everyday as my work desktop for almost nine months. I’d be lying if I didn’t admit to missing some niceties from my Macs. However, Ubuntu is extremely usable and the gains of open source outweigh some of the annoying rough edges. I’ll also be speaking at Ubuntu Live (Use code ubu07ucm for a 35% discount).

Our software development road map is very exciting as we hope to continue innovating and contributing to Rails adoption and deployment.

  • Add Rails Machine special sauce to the base stack install on Ubuntu.
  • Complete CentOS 5 stack and rake tasks
  • Release updated railsmachine and mongrel_cluster gems (bug fixes, new features, Cap 2 compatible).
  • Add support for process monitoring, log rotation, session cleanup, and Nginx.
  • Offer Ubuntu Server for hosting customers.
  • Release free Rails Machine virtual appliances (codename: Banshee). Downloads for KVM/Qemu, Parallels, Xen, and VMWare will be available.

If you are on Linux desktop, you must try KVM for development testing. Its amazing. Virtualization doesn’t get easier. On Ubuntu, you can install the package and launch an instance with two commands.

sudo aptitude install kvm qemu
sudo kvm -hda machinify.img -m 384


Check it out!

mongrel_cluster prerelease 1.0.1.1

Posted by bradley on February 26 2007 at 07:51 AM | 0 comments

A prerelease of a new mongrel_cluster is now available. Proceed at your own risk! If you have a staging or development server, please try it out.

gem install mongrel_cluster --source http://mongrel.rubyforge.org/releases/

This one has some new features in it that need to be tested on all unix platforms. Please run—clean and cluster::status on every *nix you can find. I run linux so the rest are up to you.

Thanks to the following for patches, bug reports, and suggestions: Corey Donahue, Matt Trott, Donnie Jones, Matte Edens, Joey Geiger, Nathan Vack, and others.

New Features

  • The cluster::start, stop and restart commands now support—clean. On start, any orphaned pid_files will be removed and any missing members will be started. Running members will be ignored. On stop, orphaned members (with missing pids) will be killed. On restart,—clean will be passed to stop and start. Feel the healing power of the pack!
  • cluster::status – Reports the status of the cluster members with respect to pid_file and the existence of the process. Returns 0 if ok, 2 if not.
  • —only PORT – run a command only a specific port.
  • Capistrano – added variables for the mongrel_rails path, pid_file, log_file, clean, and a task for status.
  • The init.d script (resources/mongrel_cluster) will now create /var/run/mongrel_cluster and chown to a defined user on start (see file). To fully use this feature, update your cluster yml files to store the pidfile in /var/run/mongrel_cluster. This will support cleaning up orphaned pidfiles at boot time. For example: pid_file: /var/run/mongrel_cluster/foo.pid

Changes/Fixes

  • Each mongrel_rails process now has its own log file.
  • Improved parsing of log_file and pid_file filenames to support ”.” in the names.
  • start/stop messages for each port
  • Fixed a parameter bug with mongrel_cluster_ctl calling mongrel_rails.
  • Default pid_file is now “tmp/pids/mongrel.pid” to match Rails rake tasks. NOTE: I recommend using /var/run/mongrel_cluster so pids are properly cleaned up after a crash.

How does it work?

check status of your cluster
[me at fluxura ~]$ mongrel_rails cluster::status -C 
/etc/mongrel_cluster/fluxura.conf
found pid_file: /var/run/mongrel_cluster/fluxura.8000.pid
mongrel_rails (port: 8000, pid:27286) is running...

found pid_file: /var/run/mongrel_cluster/fluxura.8001.pid
mongrel_rails (port: 8001, pid:27289) is running...

simulate process death
[me at fluxura ~]$ kill -9 27289

uh-oh
[me at fluxura ~]$ mongrel_rails cluster::status -C 
/etc/mongrel_cluster/fluxura.conf
found pid_file: /var/run/mongrel_cluster/fluxura.8000.pid
mongrel_rails (port: 8000, pid:27286) is running...

found pid_file: /var/run/mongrel_cluster/fluxura.8001.pid
!! mongrel_rails (port: 8001) is not running...

clean ignores the good process, removes orphaned pid_file, and starts new process. healing pack power!
[me at fluxura ~]$ mongrel_rails cluster::start --clean -C 
/etc/mongrel_cluster/fluxura.conf
already started port 8000
missing process: removing /var/run/mongrel_cluster/fluxura.8001.pid
starting port 8001

Give it a go and let me know…

railsmachine-0.1.2.gem

Posted by bradley on November 29 2006 at 02:58 AM | 0 comments

The Rails Machine gem has been updated with a few fixes and minor enhancements. Update on your local machine with sudo gem update railsmachine.

Please put in a ticket if you have any problems.