NOTE: See also my Dreamhost Recipe
DISCLAIMER: THIS SCRIPT CREATES DIRECTORIES, MAKES FILES, AND LAUNCHES PROCESSES ON YOUR TEXTDRIVE ACCOUNT. USE AT YOUR OWN RISK!
IT IS ALSO EXPERIMENTAL AND MAY HAVE BUGS!
Shovel is a customized Capistrano deployment file to setup config files on TextDrive in order to make it easier to start running Rails with lighttpd. It could also be modified to work with other shared hosts who run lighttpd.
Download Shovel lighttpd + Capistrano Task
It automatically does the tasks recommended on 10-15 pages of instructions spread across the following blogs:
Capistrano was previously called Switchtower.
Shovel uses a basic Capistrano task to ssh into your TextDrive account and do the following things:
And, it runs in under a minute, automatically!
There are three steps, or a fourth if you are on Mac OS X. You will also have to re-route your Apache config to lighttpd using the TextDrive webmin.
The Ruby built-in to Mac OS X is broken in regards to Capistrano. (Reportedly, it is also broken on Ubuntu and you must use the pure Ruby version of SSH).
Fortunately, you can run my ru-ra-lim.sh script to automatically rebuild Ruby, Rails, lighttpd, and MySQL on your local box.
Or, install Darwinports and reinstall Ruby with
sudo port install ruby sudo port install rb-rubygems sudo gem install rails --include-dependencies sudo gem install capistrano --include-dependencies mkdir ~/backup_ruby sudo mv /usr/bin/ruby ~/backup_ruby/ sudo mv /usr/bin/ri ~/backup_ruby/ sudo mv /usr/bin/irb ~/backup_ruby/ ln -s /opt/local/bin/ruby /usr/bin/ruby
You may also have to re-install other compiled gems, like RMagick.
sudo gem install capistrano --include-dependencies rehash cap --apply-to path_to_my_rails_app
The script requires you to setup your base domain first. For example, I signed up to TextDrive with topfunky.net, so I need to start the whole process with topfunky.net before I setup deployment for all my other domains.
NOTE: You can change this, but the script assumes it will be done first, so you’ll have to modify the lighttpd.conf if you start with another site first.
Ok…to prep a Rails project for Capistrano, do:
cd my_rails_app/config rm deploy.rb wget http://topfunky.net/svn/shovel/deploy.rb
Now edit the customized deploy.rb. While the file itself is 300+ lines long, modifying it is easy.
Change the following four lines at the top of the script:
set :application, 'my_domain_name.com' # The one you are deploying. set :user, "funky_buffalo" # Your TextDrive username set :txd_primary_domain, 'my_domain_name.com' # The domain you ssh to for your server. set :lighty_port, 00000000 # The port given to you by TextDrive for running lighttpd
Capistrano needs to use the cached password for Subversion. Do a ‘svn co—username my_user_name http://my_domain.com/svn/my_project.com’ anywhere on your server (a tmp directory or wherever).
Now it’s time for the magic.
rake remote:exec ACTION=setup_lighty
You will be prompted for your ssh password.
If something goes wrong during the process, you can re-run it again, or run ACTION=teardown_lighty to delete the folders that were made (the cron job will have to be deleted manually).
To test it, dial up http://your_domain.com:your_port in a web browser. If you don’t see it, you might have to ssh into your server and manually start lighttpd with
./lighttpd/lighttpdctrl start
You will also have to use the TextDrive webmin to re-route Apache to your new lighttpd port (Painless lighttpd).
Now, you can push your changes to the live server by checking them into Subversion and running:
rake deploy
Isn’t that great?
Here are some more things you can do with this script.
UPDATE: Don’t install daedalus
You can run multiple websites or subdomains from the same lighttpd config file.
Capistrano is fantastically easy to work with, but will die easily, as it should. It’s made for deploying rock solid applications to production, or to fail if anything goes wrong.
More on that in the next few weeks.
If you re-install Ruby using DarwinPorts, your new Rails projects will reference the new location in the hash-bang:
#!/opt/local/bin/ruby
You’ll have to edit this to run dispatch.fcgi (and others in ./script) on a remote server.
Or, start your new project with
rails my_project.com --ruby /usr/local/bin/ruby
Download Shovel lighttpd + Capistrano Task
Comment about Shovel on my Blog
Subversion repo at
svn co http://topfunky.net/svn/shovel shovel
Geoffrey Grosenbach, boss@topfunky.com