"Norman Rasmussen" writes:
- On Thu, Aug 28, 2008 at 5:10 PM, Pravin sinha <[EMAIL PROTECTED]> wrote:
- > PyYIMt:
- >
- > 2. Is there any way to put the process in background using configuration.
- > Something similar to <background> in pyMSNt.
-
- 2. There's no option to run the transport in the background in the config
- file. The easiest way to do this is with whatever way is preferred by your
- disto (often it's start-stop-daemon or similar). Worst case run the
- transport with '&' at the end of the line to force it to background.
I've attached the patch I put into pkgsrc for the
yahoo-transport. (it and the rest of the transports can be found
at pkgsrc-wip.sf.net, as py-jabber-yahoo-transport,
py-jabber-msnt, py-jabber-aimt, py-jabber-proxy65, and
py-jabber-palaver)
--
Eric Schnoebelen [EMAIL PROTECTED]
http://www.cirr.com
I can't remember if I'm the good twin or the evil one.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"py-transports" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/py-transports?hl=en
-~----------~----~----~----~------~----~------~--~---
$NetBSD$
--- yahoo.py.orig 2007-11-06 15:26:28.000000000 -0600
+++ yahoo.py
@@ -1251,6 +1251,26 @@ if __name__ == '__main__':
if 'PID' in os.environ:
config.pid = os.environ['PID']
loadConfig()
+ if config.daemonize:
+ try:
+ pid = os.fork()
+ if pid > 0:
+ sys.exit(0) # exit from the parent
+ except OSError, e:
+ print "Fork failed: (" + e.errno + ") " + e.strerror
+ sys.exit(1)
+ # now we're in the child, redirect stdin/out/error
+ for f in sys.stdout, sys.stderr: f.flush()
+ si = file('/dev/null', 'r')
+ if config.debugFile:
+ so = file(config.debugFile, 'a+')
+ else:
+ so = file('/dev/null', 'a+')
+ os.dup2(si.fileno(), sys.stdin.fileno())
+ os.dup2(so.fileno(), sys.stdout.fileno())
+ os.dup2(so.fileno(), sys.stderr.fileno())
+ # all done daeonizing.
+
if config.pid:
pidfile = open(config.pid,'w')
pidfile.write(`os.getpid()`)