fab-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Fab-user] sudo and background task


From: Jeff Forcier
Subject: Re: [Fab-user] sudo and background task
Date: Sat, 13 Jun 2009 09:34:48 -0400

I'm guessing the reason it hangs is because Fabric actually executes
things inside a call to a shell by default; if my understanding of '&'
backgrounding is accurate, this means that while the process *is*
being backgrounded with respect to the shell, the shell is still
sitting around waiting for its child processes (i.e. the daemon) to
exit. Thus, sudo appears to "hang" because the daemon hasn't exited =>
the shell hasn't exited => sudo waits forever because it's waiting on
the shell.

Others can probably confirm/deny this, I'm still not quite as much of
a process ninja as I'd like :)

Off the top of my head, you could try to use something other than '&'
to background the process, like 'nohup' or an immediately-detached
screen session (pretty sure screen has CLI options for "run this and
immediately detach").

When I have some time this weekend I'll poke around a bit to remind
myself of the ramifications of trying to background processes like
this, since it sounds like a good FAQ to have.

Best,
Jeff



On Tue, Jun 9, 2009 at 3:50 PM, webmaster<address@hidden> wrote:
> Hi,
>
> I'm trying to use fabric to deploy my django site. It needs to start some
> servers as deamon, (using &), but this makes sudo hang.
> My current, far from optimal solution is to spawn a thread, that joins the
> main thread with a 1 sec timeout:
> -----------------
> from threading import Thread
> class sudobreak(Thread):
>  def __init__ (self):
>    Thread.__init__(self)
>  def run(self):
>     sudo("nohup /run_server.sh", user="sites")
> t = sudobreak()
> t.start()
> t.join(1)
> -----------------
> Obviously, this solution is anything but optimal :/ (but it works!)
>
> Is there any solution to this?
>
> Thanx,
> Colin
>
>
>
> _______________________________________________
> Fab-user mailing list
> address@hidden
> http://lists.nongnu.org/mailman/listinfo/fab-user
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]