문제

I'm using python fabric to deploy binaries to an ec2 server and am attempting to run them in background (a subshell).

All the fabric commands for performing local actions, putting files, and executing remote commands w/o elevated privileges work fine. The issue I run into is when I attempt to run the binary.

with cd("deploy"):
        run('mkdir log')
        sudo('iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080', user="root")
        result = sudo('./dbserver &', user="root") # <---- This line
        print result
        if result.failed:
            print "Running dbserver failed"
        else:
            print "DBServer now running server" # this gets printed despite the binary not running

After I login to the server and ps aux | grep dbserver nothing shows up. How can I get fabric to execute the binary? The same command ./dbserver & executed from the shell does exactly what I want it to. Thanks.

도움이 되었습니까?

해결책

This is likey reated to TTY issues, and/or that you're attempting to background a process.

Both of these are discussed in the FAQ under these two headings:

http://www.fabfile.org/faq.html#init-scripts-don-t-work

http://www.fabfile.org/faq.html#why-can-t-i-run-programs-in-the-background-with-it-makes-fabric-hang

Try making the sudo like this:

sudo('nohup ./dbserver &', user=root, pty=False)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top