Configure your Free Facebook Joyent Accelerator for Capistrano

Right now Joyent is giving away free Accelerator accounts to Facebook developers. I love free stuff so this is so cool I could just cry. Free hosting with one of the premier Ruby on Rails hosts. I normally have to eat bags of M&Ms to be this happy.

Not all is roses. There is a dark side to this free hosting. Setting it up will make you want to cry. I am a developer, not a Solaris system administrator and so getting my application deployed was like having a vasectomy and being totally conscious the entire time. In hopes of saving time in the future for myself and others here is how to configure your Facebook Rails application for deployment via Capistrano on a Joyent Accelerator. The ideas aren’t mine. I stole everything from all over the place. I added links at the bottom where I found some of the information. The rest of it I will just feel guilty about.

  1. Setup your shell for capistrano. Follow the link for the how and why.
    Note my $HOME/.ssh/environment file contains this:

      Also be careful so that you don't edit ssh_config instead of sshd_config not that anyone would ever be so stupid and do that.  :-)
  2. Make sure you have the Capistrano gem installed on your local machine:
    sudo gem install capistrano</pre>
  3. capify your application: In the root of your rails application run this:
    capify .</pre>
  4. You will now have a deploy.rb in your config directory. Replace it with this deploy.rb. Then be sure to replace the XXXXXXXX with the username provided to you in your welcome email from Joyent. Then look for the sections of deploy.rb that contain capital letters and enter in the relevant values. These will include your application name, your domain name, and the path to your repository.
  5. Now create a directory inside your config directory and name accelerator. Then add the following three files into it: accelerator_tasks.rb - contains Capistrano recipes specific to the Joyent Accelerator. apache_vhost.erb - configures apache to point to your rails application smf_template.erb - starts up mongrel automatically for you when you system starts
  6. Now we need a mongrel_cluster.yml file. Create a file called mongrel_cluster.yml inside of your config directory and put this in it: port: "8000" environment: production address: pid_file: /home/XXXXXXX/web/APP-NAME/shared/pids/ log_file: /home/XXXXXXX/web/APP-NAME/shared/log/mongrel.log servers: 3 docroot: /home/XXXXXXX/web/APP-NAME/current/public cwd: /home/XXXXXXX/web/APP-NAME/current You will need to edit the paths to match the paths you setup in deploy.rb. This likely means that you will need to replace XXXXXXX with your joyent username and APP-NAME with the name of your application.
  7. Subversion needs to know how to talk to your repository if it is password protected. ssh into the server and do this inside your home directory: svn co PATH TO YOUR PROJECT You can delete the directory when it is done. You do this so that your svn username and password are cached on the server which means that Capistrano will be able to checkout files.
  8. While you are logged into the server be sure to create an empty database. The name should match the name in your database.yml file.
  9. Be sure to enter the proper username for root into your database.yml file.
  10. Now for the exciting part: Run
    cap deploy:setup</pre> inside of the root of your Rails project.  It should run successfully.  If not I am very sorry.
  11. Then do this: cap deploy:cold
  12. </ol> You should be up and running at that point. More helps and information: Joyent's quickstart. Although I would bypass that and look at the main how to found here. How to use Capistrano on a new Joyent Accelerator.

Leave a Reply