You should follow me on Twitter.


Deploying Rails apps with Beanstalk and Passenger

In my early Ruby on Rails days, each time I wanted to deploy a new version of an application on the server, I had to update the code from SVN, create new symlinks, […] and restart a bunch of Mongrels.

SVN Help

Command line work. DRY?

Capistrano took over, which made the whole process a lot easier. Deploying now meant to type capd in a Terminal window, TextExpander made cap deploy out of it and the capistrano script took care for all the stuff mentioned above.

Beanstalk Logo

Nowadays my SVN repositories are hosted on Beanstalk instead of my own server. So after committing my changes I simply go to the project’s Beanstalk page and press a button: Deploy. Done.

Thanks to my Passenger setup, Beanstalk can just upload my new files to the server via FTP—and that’s all there is to do.

Passenger Logo

And again, thanks to Passenger, it’s almost as easy as that to install a new app: Just configure your Apache to serve the public/ folder of your Rails app and Passenger takes care of the rest. Easy as pie.

A word of caution though: Depending on your server’s power you may want to decrease the maximum amount of running passenger instances—the default is set up to 6, in which case Rails may eat your RAM for lunch (if you’re on a tiny box like I am).

To do this, edit your httpd.conf and add the following line:

PassengerMaxPoolSize 2

A post on this topic which helped me a lot is Phusion Passenger (mod_rails) Memory Management.


2 Other Comments

Comments

  1. Quote

    Nice to see something simpler that Capistrano. I tend to strive for the simplest tool for the job, too, so this article is a real inspiration. But I really do not want to open your Po… whatever. :) No, not really.

  2. Quote

    When I just read the email containing your comment, I had no idea what you’re talking about. After a while I was done wondering and clicked through to this page—you meant the “Popego” :D

    Well, from that point of view… I think you’re right about it. Strange name. And—as long as the site is built well (which it unfortunately still isn’t)—there’s no great value in having it. I’ll reconsider whether it may stay in the future.

    Thanks for your comment!

  3. Quote

    Nice write up. We posted it on our blog for other Beanstalk customers.

  4. Quote

    Hi,

    thanks for mentioning my post! It’s “Julian”, not “Jason” though ;-)

    Thanks for Beanstalk as well—it is a very nice addition to my set of tools!

    Julian

    This comment was originally posted on http://www.wildbit.com/)“>Wildbit

  5. Quote

    Thanks for posting—I appreciate it!

    Keep up the great work you do with Beanstalk :-)

  6. Quote
    Chris Nagele said March 12, 2009, 8:06 pm:

    Heh, I knew I posted that too fast :) Thanks for the correction.

    We love reading posts like this and sharing them with customers.

    This comment was originally posted on http://www.wildbit.com/)“>Wildbit

  7. Quote

    Thanks for the tip Julian. I setup it yesterday but I don’t know how to restart passenger after deployment. Capistrano did it for me by “touch restart.txt” after deployment, but Beanstalk doesn’t have that option. How did you solve that problem?

  8. Quote

    Hi Zoran,

    you’re right, this is what I left open in my post—but Beanstalk has you covered on this as well ;-)

    You could use a web hook from the integrations’ tab in your Beanstalk repository and specify a PHP script or similar to touch restart.txt. Wildbit actually provides a description on how to set this up—you only need to change the commands it executes.

    [1] http://www.wildbit.com/blog/2009/02/10/327/

    The second solution, less to set up but more work in the end: Include restart.txt into your repository and make sure to change it before you deploy your app.

    I’d prefer the first solution, but didn’t implement it yet :-)

    Julian

  9. Quote

    Considering our site is run entirely on Ruby On Rails, I’ll forward this to my programmer. Thanks for the valuable information. Keep the posts coming!

  10. Quote
    jackie @ com said November 6, 2009, 1:18 pm:

    thanks for the post!!

Leave a Comment

(required)

(required)

Formatting Your Comment

The following XHTML tags are available for use:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

URLs are automatically converted to hyperlinks.

Additional comments powered by BackType