fab-user
[Top][All Lists]
Advanced

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

[Fab-user] Running a fabric script in the background, without stdin


From: Daniel Gonzalez
Subject: [Fab-user] Running a fabric script in the background, without stdin
Date: Sun, 22 Apr 2012 19:37:49 +0200

Hello,

I have a daemon which uses fabric to perform some remote tasks. I am using public key authentication, so that no user intervention is needed.
Fabric does not seem to handle this case very well. It uses the public-key mechanism as expected, but it also opens an interactive channel - which is actually not needed.
This seems to affect processes with fabric run in the background (daemons), which get stopped trying to access stdin.

I am using Python 2.7.2 and fabric:
VERSION = (1, 4, 0, 'final', 0)

I have simplified the use case for this post. The simplified script is as follows (fabric_daemon.py)

=======================================
#!/usr/bin/env python

from fabric.api import env, output, run, sudo

env.host_string = "address@hidden:22"

sudo('ps -ef', pty = False)
=======================================

If I run this script in the background, it stops when executing the sudo command.

./fabric_daemon.py &
address@hidden:22] sudo: ps -ef
[1]+  Stopped                 ./fabric_daemon.py

If I run it with nohup, I get the following:

nohup: ignoring input and appending output to `nohup.out'
address@hidden:22] sudo: ps -ef
Traceback (most recent call last):
  File "./fabric_daemon.py", line 7, in <module>
    sudo('ps -ef', pty = False)
  File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/fabric/network.py", line 457, in host_prompting_wrapper
    return func(*args, **kwargs)
  File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/fabric/operations.py", line 932, in sudo
    user=user)
  File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/fabric/operations.py", line 815, in _run_command
    combine_stderr)
  File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/fabric/thread_handling.py", line 12, in wrapper
    callable(*args, **kwargs)
  File "/home/gonvaled/.virtualenvs/python2.7.2-wavilon1/lib/python2.7/site-packages/fabric/io.py", line 156, in input_loop
    byte = msvcrt.getch() if win32 else sys.stdin.read(1)
IOError: [Errno 9] Bad file descriptor

Is there a mechanism to force fabric to *not* use stdin?

Thanks,
Daniel Gonzalez

reply via email to

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