Capistrano pitfalls
- To capify yor application start here and opt for the mongrel option. The writeup should get you through to the point where your application is copied to the server and capistrano fails to start it. But that's a good start. Also helpful was this article to get started with the mongrel part. What helped me was to create a group on the server called 'rubydev' to not do everything as root:
CODE:
-
# addgroup rubydev
-
# mkdir /u
-
# chmod g+rw /u
-
# chmod a+s /u
-
# adduser <insert_your_name_here> rubydev
-
- Someone at Capistrano assumes you want to run your mongrels as user 'app'. That's not the worst idea, so if you can, create such a user on your server. Otherwise, there's an option in deploy.rb to change the runner user (and nil is a valid option).
CODE:
-
# adduser --system --ingroup rubydev --disabled-password --disabled-login --home /u/apps/ --no-create-home app
-
- The first milestone is to be able to deploy without error.
CODE:
-
cap deploy:cold
This results in a long list of actions which should result in 'command finished' and no errors above. To get this working you will quite likely have to
- Create the database
- Install the gems
-
- The mongrel pid files are required to stop the servers with capistrano. when running cap deploy:stop, capistrano uses a script called reaper from rails. This reaper looks for pid files in tmp/pids named dispatch
.<port>.pid. So name the pid files in your mongrel_cluster.yml "dispatch.pid" (the port number is inserted by mongrel). - If apache runs on https and mongrel on http, the rails application does not know how to redirect properly. It has to be told. Put this into your host config:
CODE:
-
RequestHeader set X_FORWARDED_PROTO 'https'
-
- Watch out when installing the mysql gem. The C implementation of the database connector uses a socket which resides either in /tmp/mysql.sock, /var/run/mysqld/mysqld.sock or other locations near those. Since var/run and tmp are wiped on reboot, symlinking is not an option. Ok, you could put the socket directive in database.yml, but if you're lazy you might not want to have a separate database.yml for production purposes.
I don't have a clear solution here yet. Especially annoying is that by default, the mysql directory is only accessible by the mysql user. pff.CODE:-
cap deploy:cold
-
- Maybe you would like to run the app in development mode? There's two places to set that: once for capistrano, and once for mongrel. Capistrano checks in deploy.rb:
CODE:
-
set :rails_env, "development"
-
Please tell me if this was useful for you, or what I could improve.
back