From: Faiyaz Ahmed Date: Tue, 22 Jul 2008 22:32:01 +0000 (+0000) Subject: * Slices w/ initscripts were starting repeatedly because the flag that signals the... X-Git-Tag: NodeManager-1.7-21~2 X-Git-Url: http://git.onelab.eu/?p=nodemanager.git;a=commitdiff_plain;h=db6a282730892b350c31293976598a3abbdb026d * Slices w/ initscripts were starting repeatedly because the flag that signals the initscript has not changed was being toggled after the fork(). Fixed. --- 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):