From db6a282730892b350c31293976598a3abbdb026d Mon Sep 17 00:00:00 2001 From: Faiyaz Ahmed Date: Tue, 22 Jul 2008 22:32:01 +0000 Subject: [PATCH] * Slices w/ initscripts were starting repeatedly because the flag that signals the initscript has not changed was being toggled after the fork(). Fixed. --- accounts.py | 7 +++++-- sliver_vs.py | 9 +++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/accounts.py b/accounts.py index 3413e9c..efac0ad 100644 --- a/accounts.py +++ b/accounts.py @@ -146,8 +146,11 @@ class Worker: def _stop(self): self._acct.stop() def is_running(self): - status = self._acct.is_running() - if not status: logger.verbose("Worker(%s): is not running" % self.name) + if self._acct.is_running(): + status = True + else: + status = False + logger.verbose("Worker(%s): is not running" % self.name) return status def _destroy(self, curr_class): diff --git a/sliver_vs.py b/sliver_vs.py index 376bf93..8ab08bc 100644 --- a/sliver_vs.py +++ b/sliver_vs.py @@ -163,6 +163,8 @@ class Sliver_VS(accounts.Account, vserver.VServer): if self.rspec['enabled'] > 0: logger.log('%s: starting in %d seconds' % (self.name, delay)) time.sleep(delay) + # VServer.start calls fork() internally, + # so just close the nonstandard fds and fork once to avoid creating zombies child_pid = os.fork() if child_pid == 0: if self.initscriptchanged: @@ -174,14 +176,13 @@ class Sliver_VS(accounts.Account, vserver.VServer): os.close(fd) try: self.chroot_call(install_initscript) - self.initscriptchanged = False except: logger.log_exc(self.name) - # VServer.start calls fork() internally, - # so just close the nonstandard fds and fork once to avoid creating zombies tools.close_nonstandard_fds() vserver.VServer.start(self) os._exit(0) - else: os.waitpid(child_pid, 0) + else: + os.waitpid(child_pid, 0) + self.initscriptchanged = False else: logger.log('%s: not starting, is not enabled' % self.name) def stop(self): -- 2.43.0