twistd不会给我一个shell提示符或日志

时间:2012-08-07 18:00:30

标签: twisted

我正在调用一个扭曲的python程序:

twistd -l twisted.log -y controller.py

基于我读过的所有文档:

  • l应该将STDERR的输出定向到日志文件
  • 你应该守护这个,并给我一个shell提示

代替:

  • 日志文件未受影响
  • 所有调试内容都转到stderr(来自'import logging')
  • 应用程序没有守护进程(所以我必须保持登录状态)

有人可以指出我正确的方向吗?感谢。


编辑:

tac包含:

from twisted.internet import protocol, reactor  
from twisted.application import service  

application = service.Application('myapp daemon')  

dbUpdateService= DbUpdater_UpdateService()  
dbUpdateService.setServiceParent(application)  
dbUpdateService.startService()  

# repeat with 3x services  

reactor.run()

2 个答案:

答案 0 :(得分:1)

看起来你似乎没有使用twistd

  1. -y选项读取.tac文件,而不是.py文件。从技术上讲,.tac也是Python源代码,但它有一些额外的规则,它不应该是一个模块。有一些解释here
  2. -l选项从twisted.python.log发送输出,而不是logging
  3. 你的应用程序可能不是守护进程,因为你在controller.py中做了你不应该做的随机游戏(该文件在守护进程之前执行),但是你没有附加controller.py所以我真的不知道。
  4. 请提出更详细的问题,了解您将来的实际行动。如果您的应用程序没有任何代码,则上述内容主要是猜测。

答案 1 :(得分:1)

这可能无法解决守护程序问题,但是关于你的日志文件,你使用的是twisted.python.log吗?使用log.msg和log.err获取与日志相关的输出。 查看http://twistedmatrix.com/documents/current/core/howto/logging.html

如果你使用的是twistd,你也不需要调用log.startLogging。