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 = "myuser@myhost:22"
sudo('ps -ef', pty = False)
=======================================
If I run this script in the background, it stops when executing the sudo
command.
./fabric_daemon.py &
[myuser@myhost: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'
[myuser@myhost: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
_______________________________________________
Fab-user mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/fab-user