[Twisted-Python] [newb] daemon question
I have put together a simple twisted server using xmlrpc and process. I want to run this server as a unix daemon. Specifically, detach from controlling terminal, and redirect stdout, stderr to a log file. What is the easiest approach, and where to look for documentation on this? ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] [newb] daemon question
I often use nohup for this sort of thing. An alternative would be to add it to /etc/init.d and /etc/rc?.d Cheers, Jason On Fri, Nov 5, 2010 at 1:40 PM, Neal Becker ndbeck...@gmail.com wrote: I have put together a simple twisted server using xmlrpc and process. I want to run this server as a unix daemon. Specifically, detach from controlling terminal, and redirect stdout, stderr to a log file. What is the easiest approach, and where to look for documentation on this? ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python -- Jason Rennie Research Scientist, ITA Software 617-714-2645 http://www.itasoftware.com/ ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] [newb] daemon question
On Nov 5, 2010, at 1:40 PM, Neal Becker wrote: I have put together a simple twisted server using xmlrpc and process. I want to run this server as a unix daemon. Specifically, detach from controlling terminal, and redirect stdout, stderr to a log file. What is the easiest approach, and where to look for documentation on this? Write your server as a .tac file or twistd plugin, and then run twistd without -n. See: http://twistedmatrix.com/documents/10.1.0/core/howto/application.html http://twistedmatrix.com/documents/10.1.0/core/howto/tap.html ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] [newb] daemon question
On Fri, Nov 5, 2010 at 17:40, Neal Becker ndbeck...@gmail.com wrote: I have put together a simple twisted server using xmlrpc and process. I want to run this server as a unix daemon. You might want to have a look at daemontools (http://cr.yp.to/daemontools.html). It will also take care of restarting your daemons if they die. C ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] More daemonize() / OSX API / USING_FORK_WITHOUT_EXEC_etc.
Hi, A while back on Oct 13, 2010, at 7:20 PM, James Y Knight wrote: You need to avoid using or importing any OSX APIs until after the daemonization has occurred. Unfortunately, twisted executes the entire script file before daemonizing. [that's unfortunate for other reasons besides this, too] Here's a corrected version of your script which works properly. It defers importing Quartz until the reactor is running, by moving it into a function called by reactor.callWhenRunning(). Deferring OSX API's until after daemonisation was the solution. My test script, fixed by James, works on macbook, but when I run it on a remote OSX server mini, it doesn't. It crashes as before with USING_FORK_WITHOUT_EXEC_IS_NOT_SUPPORTED_BY_FILE_MANAGER) . Both machines run the same versions of python, pyobjc, twisted. Some digging showed that on the mini twisted.application.reactors imports zope.interface, which in turn runs this: __import__('pkg_resources').declare_namespace(__name__) and this causes Carbon to be loaded, before daemonisation. I can't defer loading reactor because I need it to make things tick, so I'm stuck. Could this be related to http://twistedmatrix.com/trac/ticket/4644 ? Any clues to why pkg_resources would cause Carbon to load on one machine, but not on another? Any clues to prevent it these modules from loading? Local: System Version: Mac OS X 10.6.4 (10F569) Kernel Version: Darwin 10.4.0 Remote: System Version:Mac OS X Server 10.6.4 (10F569) Kernel Version: Darwin 10.4.0 Thanks, Erik___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] [newb] another process question
Using this code: ... def processEnded(self, reason): print processEnded, task %s, status %s % (self.task, reason.value.exitCode,) Here is what I get from a normally terminated process processEnded, task ['sleep', '4']31662, status 0 But now I kill the subprocess, with SIGTERM, and I get: processEnded, task ['sleep', '15']31663, status None This seems to disagree with the twisted process doc. Instead of an exitCode, I seem to have gotten 'None' .processEnded(status): This is called when the child process has been reaped, and receives information about the process' exit status. The status is passed in the form of a Failure instance, created with a .value that either holds a ProcessDone object if the process terminated normally (it died of natural causes instead of receiving a signal, and if the exit code was 0), or a ProcessTerminated object (with an .exitCode attribute) if something went wrong. This scheme may seem a bit weird, but I trust that it proves useful when dealing with exceptions that occur in asynchronous code. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Re: [Twisted-Python] [newb] another process question
On Fri, Nov 05, 2010 at 07:28:24PM -0400, Neal Becker wrote: The status is passed in the form of a Failure instance, created with a .value that either holds a ProcessDone object if the process terminated normally (it died of natural causes instead of receiving a signal, and if the exit code was 0), or a ProcessTerminated object (with an .exitCode attribute) if something went wrong. The deal is, there are multiple kinds of 'went wrong' in the Unix process model. One kind (described the documentation you quote above) is a non-zero exit code; you can test this by running /bin/false rather than sleep 15 as your test command. Another kind is 'killed by a signal', in which case the value returned by the process encodes the number of the signal that killed it, rather than a process-defined error code. Looking at the source of the ProcessTerminated class mentioned: http://twistedmatrix.com/trac/browser/trunk/twisted/internet/error.py#L268 ...it looks like killing a process with a signal puts 'None' in the .exitCode property, and the signal number in the .signal property. The instance also has a useful str() representation if you just want to log a sensible error message. ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
[Twisted-Python] Conch as a file transfer server
Hi! I've figured out vaguely how to use Conch as a file transfer client thanks to the cftp script. I'm currently trying to adapt the simple SSH server script example (link below) to do file *serving*. I can't find any example code that actually does this or documentation on this subject. There's conch's test_filetransfer which indeed does have some server parts, but being unit tests they gloss over a lot of the things I think I need to know to get this working for an actual file server. For example, what's the difference between SSHSession and ISession? They both appear to be 'sessions' in the SSH sense. Why does ISession not do anything about subsystems? Do I need one if I'm just using a subsystem and not opening a shell? If so: is it just a stub, or does it need to implement behavior? I would guess it's just stubs, since invoking subsystems does not mean opening a shell. link to the example: http://twistedmatrix.com/documents/current/conch/examples/index.html#auto0 Ideally, does anyone have any code somewhere that actually serves a file? thanks in advance, lvh ___ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python