[Mongrel] problem restarting mongrel_cluster outside RAILS_ROOT - patch and other option

Bradley Taylor bradley at railsmachine.com
Tue Apr 17 16:13:14 EDT 2007


As I mentioned earlier, I'll fix this for the final release (any day now 
- been really busy).


However, as I wrote before, its not a good idea to put pidfiles in a 
relative directory as they won't get cleaned up after a server crash. 
For linux, /var/run/mongrel_cluster is a better location.



Matte Edens wrote:
> Sorry.  another long one.
> Wayne, I used to use that actually.  And I even tried it last night, and 
> today, before sending the email.  It didn't work using capistrano, or 
> from anywhere that wasn't a rails_root location.  There's still a 
> problem of where the command is run and where mongrel_cluster thinks 
> it's looking for the pid files.  Here's how I see it happening...
> 1) we run "cap restart" on local machine where it logs in via ssh to 
> execute remote commands
> 2) located in the /home/ssh_user directory, the remote commands run from 
> here.
> 3) restart runs a "stop/start" command sequence.  yes, I've been reading 
> the discussion of using a -USR2 command, but for this discussion we 
> ignore that until the bottom of this email.
> 4) "stop" line 101, reads the options
> 5) "read_options" line 28 calls "process_pid_file" to parse the pid_file 
> setting
> 6) "process_pid_file" sets up several variables for future use.
> Here is where it breaks down with a relative path pid_file setting.  
> None of the File.* commands are run from the cwd in that function.  
> They're run from the /home/ssh_user directory.  Now I don't know about 
> you but I don't run my applications from that directory.  Thus, with a 
> setting of "log/mongrel.pid", the port_pid_file function returns 
> "log/mongrel.8000.pid" and check_process is looking for 
> /home/ssh_user/log/mongrel.8000.pid which obviously doesn't exist.  
> Making a small change, that I am not suggesting is a fix, just 
> temporary, I rewrote this line in process_pid_file (line 40).
> @pid_file_dir = File.dirname("#{@options['cwd']}/#{pid_file}")
> That's just a test to see if it would work with the addition of the 
> cwd.  It worked of course, because now File.dirname had an absolute path 
> to parse.
> So, my suggestions from the first email, IMHO, are still valid.  Patch 
> mongrel_cluster/init.rb to either ...
> 1) Change directories in "stop" and "start" before the check_process 
> functions are called so that relative directories are handled correctly, 
> (see my pastie) or
> 2) Change the process_pid_file function to handle relative directory 
> pid_file settings by prepending the cwd setting.
> or 3) have everyone change their mongrel_cluster config files to us 
> absolute directory paths.  And, then there's the more recent discussion 
> of changing the restart command to just call a -USR2 on mongrel_rails.
> Personally, I'd like it to be fixed within mongrel_cluster so that it's 
> just picked up by everyone when they update their gem.  And instead of 
> asking everyone to put in a "after_after_deploy" capistrano task like 
> Zed mentioned in this thread.  However, I just tried the following 
> capistrano task...
> task :restart do
>   sudo "killall -USR2 mongrel_rails"
> end
> and got this error "No matching processes were found".  No idea about 
> that except that when I "ps aux | grep mongrel_rails", each command 
> starts...
> /usr/local/bin/ruby18 /usr/local/bin/mongrel_rails start -d -e 
> production -a -c /home/...
> My linux_fu is not strong enough to know how to diagnose this last issue.
> matte
> Wayne E. Seguin wrote:
>> Matte,
>> On Apr 17, 2007, at 00:09 , Matte Edens wrote:
>>> "sudo mongrel_rails cluster::restart -C [valid path to config] -- 
>>> clean"
>> Is this really a problem with mongrel cluster?
>> A "fourth" solution is to simply modify your restart task in your  
>> Capistrano recipe:
>> task :restart, :roles => :app do
>>    run(or sudo) "cd #{current_path}; mongrel_rails cluster::restart - 
>> C [valid path to config] --clean"
>> end
> ------------------------------------------------------------------------
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users

More information about the Mongrel-users mailing list