Switchtower, but please don't switch user

Manfred Stienstra, 14 Dec 2005, 15:15 in ruby on rails, last updated 19 Apr 2006, 16:36 (edit).

As most of you already know, Switchtower is a very nice way to deploy your Rails application.

When I tried to deploy one of Thijs’ applications using Switchtower, I ran into some trouble. Switchtower tried to chmod 666 the log file, but the log file was owned by thijs:thijs.

Jamis Buck asked me to submit this bug to the Rails trac site, so I did just that. To solve the problem for the time being, I added the following to my deploy configuration:

desc "Change permission of the project to avoid problems" + 
    "with source.checkout and symlink"
task :before_update_code do
  sudo "chown -R $USER #{deploy_to}"
end

desc "Set permissions on files so the webserver can work with the files"
task :after_symlink do
  sudo "chgrp -R www-data #{shared_path}/log"
  sudo "chgrp -R www-data #{shared_path}/system"
end

If you want to use this hack, make sure you change www-data to the group your webserver/application server runs under. If you’re running Debian or Ubuntu, this should work. Make sure any other directories the webserver needs to write to, like page cache directories, are also properly chgrp’d.

Comments

Add your comment

In order to fight spam on this blog, posting comments from a browser without javascript is currently not supported.