starten eines daemons aus python

Salu zäme, ich möchte einen in python geschriebenen startscript aus python starten. dazu benutze ich folgende zeilen: *def* startstopZopeInstance(path, command, quiet = 0): p = popen('%s/bin/zopectl %s' % (path, command)) result = p.close() *if* *not* quiet: *print* result *print* 'Zope started/stoped' wobei command jeweils 'start' ist. Zope wird korrekt gestartet ich erhalte dabei folgenden "traceback". gibt es eine bessere art einen derartigen doemon zu starten? danke Robert Traceback (most recent call last): File "/home/zope/Zope-2.8.5-final/lib/python/Zope2/Startup/zopectl.py", line 322, in ? main() File "/home/zope/Zope-2.8.5-final/lib/python/Zope2/Startup/zopectl.py", line 283, in main c.onecmd(" ".join(options.args)) File "/usr/local/lib/python2.3/cmd.py", line 210, in onecmd return func(arg) File "/home/zope/Zope-2.8.5-final/lib/python/Zope2/Startup/zopectl.py", line 158, in do_start ZDCmd.do_start(self, arg) File "/home/zope/Zope-2.8.5-final/lib/python/zdaemon/zdctl.py", line 234, in do_start "daemon process started, pid=%(zd_pid)d") File "/home/zope/Zope-2.8.5-final/lib/python/zdaemon/zdctl.py", line 183, in awhile sys.stdout.flush() IOError: [Errno 32] Broken pipe _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

--On 10. Februar 2006 06:50:28 +0100 robert rottermann <robert@redcor.ch> wrote:
Salu zäme, ich möchte einen in python geschriebenen startscript aus python starten. dazu benutze ich folgende zeilen:
*def* startstopZopeInstance(path, command, quiet = 0): p = popen('%s/bin/zopectl %s' % (path, command)) result = p.close() *if* *not* quiet: *print* result *print* 'Zope started/stoped'
wobei command jeweils 'start' ist.
So einfach geht das wirklich nicht. Der übliche Weg geht über das (Doppel)-Forken eines neuen Prozesses und Überlagerung des neuen Prozesses via execXX(). Dabei muß man natürlich auch auf die Ein- und Ausgabekanäle achten. Als Zoper solltest Du Dir mal das zdaemon Paket anschauen. -aj _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

Andreas Jung wrote:
--On 10. Februar 2006 06:50:28 +0100 robert rottermann <robert@redcor.ch> wrote:
Salu zäme, ich möchte einen in python geschriebenen startscript aus python starten. dazu benutze ich folgende zeilen:
*def* startstopZopeInstance(path, command, quiet = 0): p = popen('%s/bin/zopectl %s' % (path, command)) result = p.close() *if* *not* quiet: *print* result *print* 'Zope started/stoped'
wobei command jeweils 'start' ist.
So einfach geht das wirklich nicht. Der übliche Weg geht über das (Doppel)-Forken eines neuen Prozesses und Überlagerung des neuen Prozesses via execXX(). Dabei muß man natürlich auch auf die Ein- und Ausgabekanäle achten. Als Zoper solltest Du Dir mal das zdaemon Paket anschauen.
-aj
danke für die antwort, ich hatte gehoft, es genüge wenn der controllerscript die "doppelgabel" schon auf dem tisch (sprich ausgeführt) hat. wenn ich den init script von cron aus aufrufe, muss ich mich da ja auch nicht drum kümmern. robert _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de

On Friday 10 February 2006 07:34, robert rottermann wrote:
Andreas Jung wrote: danke für die antwort, ich hatte gehoft, es genüge wenn der controllerscript die "doppelgabel" schon auf dem tisch (sprich ausgeführt) hat. wenn ich den init script von cron aus aufrufe, muss ich mich da ja auch nicht drum kümmern.
Weil der das dann wohl für dich macht - es geht halt nicht anders. Schau mal hierfür eine ganze Reihe von Skripten - in den Kommentaren die sind besser als das eigentlich Rezept :) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66012 Diez _______________________________________________ python-de maillist - python-de@python.net http://python.net/mailman/listinfo/python-de
participants (3)
-
Andreas Jung
-
Diez B. Roggisch
-
robert rottermann