Exemple #1
0
 def testA(self):
     """
     __testSubscribe__
     
     Test daemon creation
     """
     # keep the parent alive
     self.pid = createDaemon(self.tempDir, True)
     try:
         try:
             if self.pid != 0 :
                 time.sleep(2)
                 details = Details(os.path.join(self.tempDir,"Daemon.xml"))
                 time.sleep(10)
                 details.killWithPrejudice()
             else:
                 while True:
                     time.sleep(1)
         except:
             pass
     finally:
         if self.pid == 0:
             os._exit(-1)
         else:
             os.system('kill -9 %s' % self.pid)
Exemple #2
0
    def testA(self):
        """
        __testSubscribe__

        Test daemon creation
        """
        # keep the parent alive
        self.pid = createDaemon(self.tempDir, True)
        try:
            try:
                if self.pid != 0:
                    time.sleep(2)
                    details = Details(os.path.join(self.tempDir, "Daemon.xml"))
                    time.sleep(10)
                    details.killWithPrejudice()
                else:
                    while True:
                        time.sleep(1)
            except:
                pass
        finally:
            if self.pid == 0:
                os._exit(-1)
            else:
                os.system('kill -9 %s' % self.pid)
Exemple #3
0
    def startDaemon(self, keepParent=False, compName=None):
        """
        Same result as start component, except that the comopnent
        is started as a daemon, after which you can close your xterm
        and the process will still run.

        The keepParent option enables us to keep the parent process
        which is used during testing,
        """
        msg = "Starting %s as a daemon " % self.config.Agent.componentName
        print(msg)
        if not compName:
            compName = self.__class__.__name__
        compSect = getattr(self.config, compName, None)
        msg = "Log will be in %s " % compSect.componentDir
        print(msg)
        # put the daemon config file in the work dir of this component.
        # FIXME: this file will be replaced by a database table.
        compSect = getattr(self.config, self.config.Agent.componentName, None)
        pid = createDaemon(compSect.componentDir, keepParent)
        # if this is not the parent start the component
        if pid == 0:
            self.startComponent()
Exemple #4
0
    def startDaemon(self, keepParent=False, compName=None):
        """
        Same result as start component, except that the comopnent
        is started as a daemon, after which you can close your xterm
        and the process will still run.

        The keepParent option enables us to keep the parent process
        which is used during testing,
        """
        msg = "Starting %s as a daemon " % (self.config.Agent.componentName)
        print(msg)
        if not compName:
            compName = self.__class__.__name__
        compSect = getattr(self.config, compName, None)
        msg = "Log will be in %s " % (compSect.componentDir)
        print(msg)
        # put the daemon config file in the work dir of this component.
        # FIXME: this file will be replaced by a database table.
        compSect = getattr(self.config, self.config.Agent.componentName, None)
        pid = createDaemon(compSect.componentDir, keepParent)
        # if this is not the parent start the component
        if pid == 0:
            self.startComponent()
Exemple #5
0
    if not opts.inifile:
        sys.exit('No configuration specified')
    cfg = loadConfigurationFile(opts.inifile)

    component = cfg.Webtools.application
    workdir = getattr(cfg.Webtools, 'componentDir', '/tmp/webtools')
    if workdir is None:
        workdir = '/tmp/webtools'
    root = Root(cfg)
    if opts.status:
        daemon = Details('%s/Daemon.xml' % workdir)

        if not daemon.isAlive():
            print("Component:%s Not Running" % component)
        else:
            print("Component:%s Running:%s" % (component, daemon['ProcessID']))
    elif opts.kill:
        daemon = Details('%s/Daemon.xml' % workdir)
        daemon.kill()
        daemon.removeAndBackupDaemonFile()
    elif opts.terminate:
        daemon = Details('%s/Daemon.xml' % workdir)
        daemon.killWithPrejudice()
        daemon.removeAndBackupDaemonFile()
    elif opts.daemon:
        createDaemon(workdir)
        root.start(False)
    else:
        root.start()
Exemple #6
0
    if not opts.inifile:
        sys.exit('No configuration specified')
    cfg = loadConfigurationFile(opts.inifile)

    component = cfg.Webtools.application
    workdir = getattr(cfg.Webtools, 'componentDir', '/tmp/webtools')
    if workdir is None:
        workdir = '/tmp/webtools'
    root = Root(cfg)
    if opts.status:
        daemon = Details('%s/Daemon.xml' % workdir)

        if not daemon.isAlive():
            print("Component:%s Not Running" % component)
        else:
            print("Component:%s Running:%s" % (component, daemon['ProcessID']))
    elif opts.kill:
        daemon = Details('%s/Daemon.xml' % workdir)
        daemon.kill()
        daemon.removeAndBackupDaemonFile()
    elif opts.terminate:
        daemon = Details('%s/Daemon.xml' % workdir)
        daemon.killWithPrejudice()
        daemon.removeAndBackupDaemonFile()
    elif opts.daemon:
        createDaemon(workdir)
        root.start(False)
    else:
        root.start()