I have a bunch of scripts that are used to start similar processes across a number of servers. I'd like to condense them down to one Python script called 'START', but something weird is happening when it's run over ssh.
$ ./START APP_A
works as expected: APP_A is launched and begins doing its thing. Control is returned to the console immediately (before APP_A terminates).
$ ssh localhost /path_to/START APP_A
sort of works: APP_A is launched and begins doing its thing, but ssh doesn't print any output to the screen or return control to the console until after APP_A terminates.
I assume it's a problem with signals or file handles, but I'm at a loss. Here's the Popen call that seems to be causing the trouble:
sub = subprocess.Popen(shlex.split(cmd), stdout=open(file_out, 'a+'), stderr=subprocess.STDOUT, close_fds=True)
print 'New PID:', sub.pid
I'm using Python 2.4.3 on RHEL.
EDIT: Wrapping the Python script seems to work:
DIR="$( cd "$( dirname "$0" )" && pwd )"
pushd $DIR >> /dev/null
./START $1 &
popd >> /dev/null