1

i'm calling a twisted python program as such:

twistd -l twisted.log -y controller.py

based on all the documentation i've read:

  • l should direct the output from STDERR to the logfile
  • y should daemonize this , and give me a shell prompt

instead:

  • the log file is untouched
  • all the debug stuff goes to stderr ( from 'import logging' )
  • the app doesn't daemonize ( so i have to stay logged in )

can someone please point me in the right direction ? thanks.


edit:

the tac contains this:

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 Answers 2

1

It doesn't look like you're using twistd right.

  1. The -y option reads a .tac file, not a .py file. Technically a .tac is Python source code too, but it has a few additional rules and it isn't supposed to be a module. There's some explanation here.
  2. The -l option sends output from twisted.python.log, not logging.
  3. Your app probably isn't daemonizing because you're doing random crud in controller.py that you're not supposed to (that file is executed before daemonization), but you didn't attach controller.py so really I have no idea.

Please ask questions with more detail about what you're actually doing in the future. Without any of the code to your application, the above is mostly guesses.

1
  • Thanks for the quick response. controller.py was written to the .tac specification -- i renamed the file for syntax highlighting. is there a way to redirect logging into the -l log ? i'll update the question with the tac contents. Aug 8, 2012 at 15:52
1

This probably won't solve the daemonizing problem but regarding your log file are you using twisted.python.log? Use log.msg and log.err for your log related output. Check out http://twistedmatrix.com/documents/current/core/howto/logging.html

Oh also you don't need to call log.startLogging if you are using twistd.

1
  • 1
    the big change I ended up doing was this : twistd -y controller-production.tac > twisted.log 2>&1 & from what it looks like, I was indeed daemonizing -- but because stderr/stdout were going to the console it seemed like it wasn't. redirecting everything to a file seems to have done the trick for now! Aug 20, 2012 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.