简体   繁体   English

Python构造无法启动进程

[英]Python fabric unable to start process

I'm using python fabric to deploy binaries to an ec2 server and am attempting to run them in background (a subshell). 我正在使用python fabric将二进制文件部署到ec2服务器,并尝试在后台(子shell)中运行它们。

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 登录服务器和ps aux | grep dbserver ps aux | grep dbserver nothing shows up. ps aux | grep dbserver没有任何显示。 How can I get fabric to execute the binary? 我如何获得结构来执行二进制文件? The same command ./dbserver & executed from the shell does exactly what I want it to. 从外壳执行同一命令./dbserver &执行我想要的操作。 Thanks. 谢谢。

This is likey reated to TTY issues, and/or that you're attempting to background a process. 这很可能与TTY问题有关,和/或您正试图使流程成为后台。

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#init-scripts-don-t-work

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

Try making the sudo like this: 尝试像这样制作sudo:

sudo('nohup ./dbserver &', user=root, pty=False)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM