[Mongrel] Mongrel_rails restart and sudo

Tom Brice tom at onidle.com
Fri Jun 16 11:25:13 EDT 2006

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

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

** 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
`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
in `run'
        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?


More information about the Mongrel-users mailing list