[Mongrel] Mongrel_rails restart and sudo

Alison Rowland alisonrowland at fastmail.fm
Fri Jun 16 11:29:40 EDT 2006


"cd" does not respond to the sudo command. So separate the command  
into two lines, like so:

run "cd #{current_path}"
sudo "mongrel_rails restart"

--Alison
http://blog.alisonrowland.com

On Jun 16, 2006, at 11:25 AM, Tom Brice wrote:

> Sorry for the newbie question but I'm stumped:
>
> I have an app that requires sudo to run mongrel_rails.  For my  
> capistrano
> recipe is do it like this:
>
> sudo "mongrel_rails start -e production -p #{application_port} -d -c
> #{current_path}"
>
> Which works famously.
>
> Now I have tried several things for my restart task.  Here they are:
>
> sudo "cd #{current_path} && sudo mongrel_rails restart"
>
> That doesn't work.  For some reason the "cd..." command does not  
> work.  I'm
> assuming that is some sort of problem with capistrano or my  
> server.  So
> moving on I tried:
>
> sudo "mongrel_rails restart -c #{current_path}"
>
> to avoid having to do the "cd...".  When I do that I get this in my
> mongrel.log:
>
> ** USR2 signal received.
> ** Restarting with arguments:  ruby
> /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13/bin/mongrel_rails  
> start -e
> production -p 81 -d -c /Library/WebServer/rails/kd/current
> /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13/bin/mongrel_rails: 
> 158:in
> `exec': Operation not supported - ruby
> /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13/bin/mongrel_rails  
> start -e
> production -p 81 -d -c /Library/WebServer/rails/kd/current
> (Errno::EOPNOTSUPP)
>         from
> /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13/bin/mongrel_rails: 
> 158:in
> `run'
>         from
> /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13/lib/mongrel/ 
> command.rb:188:
> in `run'
>         from
> /opt/local/lib/ruby/gems/1.8/gems/mongrel-0.3.13/bin/mongrel_rails:247
>         from /opt/local/bin/mongrel_rails:18
>
> Which I assume is due to the "sudo" not being added to the  
> "mongrel_rails
> start..." command that is being called by "mongrel_rails restart".   
> So it
> seems that one cannot do "mongrel_rails restart" with "sudo".  My  
> ugly hack
> is to to "mongrel_rails stop" and then "mongrel_rails start".  Any  
> ideas?
>
> Now, I have control over this server and am fine with changing  
> permissions
> so that I don't have to use "sudo".  This is probably off-topic for  
> this
> list (better suited to "Server Admin for Dummies" perhaps) but how  
> do I do
> that?  I assume I need sudo because mongrel needs to write stuff to  
> a tmp
> dir that my user does not have access to.  Any pointers?
>
> Thanks,
> Tom
>
>
> _______________________________________________
> Mongrel-users mailing list
> Mongrel-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mongrel-users



More information about the Mongrel-users mailing list