Passenger/Capistrano symlink issue


#1

So, after a day of very confused investigation, I’ve found that dreamhost/passenger is not following changed symlinks (I think). What’s happening is:

~/sitename/current is a symlink -> ~/sitename/release/123

I tell capistrano to deploy the latest version of my code. It goes to ~/sitename/release/124 and pulls down the latest code from svn, and then modifies the ~/sitename/current symlink to point to ~/sitename/release/124.

Of course, apache/passenger is still running the old code (in …/123), so I go into …/123 and touch tmp/restart. This seems to restart the app, but it still runs the old code. I should note here that the root of this domain is ~/sitename/current/appname/public. As such, I’d think that, when restarted, passenger would follow the updated symlink to the new code, but this does not seem to be the case. In fact, the only way to get this to occur is to go to the web panel and edit the domain (but not actually change anything). Presumably this makes dreamhost reevaluate the root path.

Any idea why this is the case, and/or how to correct/work around it?


#2

I realize this is an old thread, but I just came across this issue and this thread via search. In case someone else has this problem, here’s what seems to be working for me.

Use this recipe to restart Passenger instead of touching tmp/restart.txt:

[code]namespace :deploy do
task :start do ; end
task :stop do ; end

This task with bounce the standalone passenger server (running the embedded nginx server).

The rails_env and passenger_port are specified in the deploy environment files, ex: “config/deploy/staging.rb”

desc "Restart Passenger server"
task :restart, :roles => :app, :except => { :no_release => true } do
run <<-CMD
if [[ -f #{release_path}/tmp/pids/passenger.#{passenger_port}.pid ]];
then
cd #{deploy_to}/current && passenger stop -p #{passenger_port} --pid-file ./tmp/pids/passenger.#{passenger_port}.pid;
fi
CMD
# restart passenger standalone on the specified port/environment and as a daemon
run "cd #{deploy_to}/current && #{try_sudo} passenger start -e #{rails_env} -p #{passenger_port} -d"
end
end
[/code]

I found it here and modified it only slightly.