Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python fabric如何在远程计算机上启动进程_Python_Linux_Fabric - Fatal编程技术网

python fabric如何在远程计算机上启动进程

python fabric如何在远程计算机上启动进程,python,linux,fabric,Python,Linux,Fabric,全部 我正在使用fabric部署我的python作业。python项目包含一个名为“run_fetchserver.sh”的shell来控制进程的启动/停止 fetch_path=$PROJECT_PATH if [ $1 = start ] then psid=`ps aux | grep "fetch_server" | grep -v "grep" | wc -l` if [ $psid -gt 1 ] then echo "fetchser

全部 我正在使用fabric部署我的python作业。python项目包含一个名为“run_fetchserver.sh”的shell来控制进程的启动/停止

fetch_path=$PROJECT_PATH
if [ $1 = start ]
then
    psid=`ps aux | grep "fetch_server" | grep -v "grep" | wc -l`
    if [ $psid -gt 1 ]
        then
        echo "fetchserver is running!"
        exit 0
    else
        pushd $fetch_path
            nohup python fetch_server.py >>start_fetchserver.log 2>&1 &
        popd
        echo "Start fetchserver service [OK]"
    fi
elif [ $1 = stop ];then
    pkill -f "fetch_server.py"
    echo "Stop fetch service [OK]"
elif [ $1 = restart ];then
    pkill -f "fetch_server.py"
    pushd $fetch_path
        nohup python fetch_server.py >>start_fetchserver.log 2>&1 &
    popd
    echo "Restart fetchserver service [OK]"
else
    echo "Usages: sh fetchserver server.sh [start|stop|restart]"
fi
这个脚本在本地运行得很好,但是当我使用fabric命令调用它时 运行(“./run_fetchserver.sh restart”)
作业根本没有在远程计算机上启动。为什么?问题终于解决了

我只更改了fabfile.py中的一行:


因此,程序在远程计算机上成功启动。

您是否在远程计算机上复制了脚本?您是否尝试在远程计算机上手动运行脚本?当结构任务不执行时,它通常会产生错误,您能否共享该错误?我认为这不是一个好的解决方案,我宁愿使用
supervisord
如果应用程序/服务器崩溃,这不会起任何作用。我不知道,我喜欢监督:/
run('./run_fetchserver.sh restart') 
run('./run_fetchserver.sh restart', pty=False)