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 12:20:52 -0400

Yea, it looks like I was correct: using & simply backgrounds the
process in the calling shell, it is not the same as daemonizing it,
which involves ensuring that the process' input and output pipes are
all disassociated from the calling terminal/shell.

It's possible to get around this with screen, as I mentioned (though
not nohup; it's similar to & in that it still blocks the exit of the
calling shell), with something like 'screen -d -m <your command>'.
Added bonus is that you can reconnect to it later if desired.

Realistically, though, I think you should make an effort to use a
"real" daemon that is controlled via an init script or *ctl binary, or
some other properly daemonizing setup. What exactly are you trying to
run? I hope you're not "deploying" a Django app with the builtin dev
HTTP server ;)

Best,
Jeff

On Sat, Jun 13, 2009 at 9:34 AM, Jeff Forcier<address@hidden> wrote:
> 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]