【问题标题】:Run a detached process with fabric and screen使用织物和屏幕运行分离过程
【发布时间】:2014-08-12 17:24:13
【问题描述】:

根据FAQ,从推荐的运行分离进程的方法中,唯一适合我的是screen,因为我无法在服务器上安装程序并且似乎无法使nohup 工作。我想:

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

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

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

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

【问题讨论】:

  • 使用 nohup 有什么错误?

标签: python linux fabric nohup


【解决方案1】:

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

我强烈建议通过进程管理器 (see Fabric's documentation suggestions) 运行此命令,因为它更易于管理(例如 service logstash stop 与在屏幕会话中查找正在运行的命令相比)并且更简洁,但您应该能够通过 Fabric 完成以下操作:

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

【讨论】:

  • 由于某种原因这不起作用。使用此命令,我看到 screenlog.0 文件在直接启动而不是从 Fabric 启动时被填充,其中 screen 似乎没有做任何事情"screen -L -d -m yes "
猜你喜欢
  • 2013-12-06
  • 2012-04-17
  • 1970-01-01
  • 2017-07-17
  • 1970-01-01
  • 2022-06-22
  • 1970-01-01
  • 1970-01-01
  • 2013-10-30
相关资源
最近更新 更多