gpt4 book ai didi

python - 使用织物和屏幕运行分离过程

转载 作者:太空狗 更新时间:2023-10-29 12:31:33 25 4
gpt4 key购买 nike

根据FAQ ,从运行分离进程的推荐方法来看,唯一对我有用的方法是 screen 因为我无法在服务器上安装程序并且似乎无法使 nohup 工作。我愿意:

  • run(command) 以便命令继续运行而不会阻塞。
  • 知道我正在运行的进程的 pid,以便稍后可以终止它。

到目前为止,nohup 重定向和 screen -md 命令 的组合对我没有用。

特别是,当直接在服务器上执行而不是通过 fabric 的运行功能运行时,运行此命令行确实有效。我相信当函数返回时进程已经关闭,我没有时间看到它:


nohup/opt/logstash/bin/logstash agent -f/home/unicryo/PVSS_projects/GenerateErrors/logstash_conf/logstash-config-minimum.cfg >> test.out 2>&1 &

最佳答案

您无法nohup 进程因为它是not really supported Fabric 。

我强烈建议通过进程管理器 ( see Fabric's documentation suggestions ) 运行此命令,因为它更易于管理(例如,service logstash stop 与在屏幕 session 中查找正在运行的命令相比)和清洁,但您应该能够通过 Fabric 摆脱类似以下的问题:

run("screen -d -m '/opt/logstash/bin/logstash agent -f /home/unicryo/PVSS_projects/GenerateErrors/logstash_conf/logstash-config-minimum.cfg'")

关于python - 使用织物和屏幕运行分离过程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25270413/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com