Exemplo n.º 1
0
    def close(self):
        """Gracefully terminates the process (if possible), removes it from the cluster, and invalidates the `Process` object."""
        
        global runningServers
        
        if self.running is True:
            if self.process.poll() is None:
                utils.kill_process_group(self.process_group_id)
            
            if self in runningServers:
                runningServers.remove(self)
            
            if self._close_console_output:
                self.console_file.close()
        
        self.process = None
        self.running = False
        
        # `self.cluster` might be `None` if we crash in the middle of `move_processes()`
        if self.cluster is not None:
            for other_cluster in self.cluster.metacluster.clusters:
                if other_cluster is not self.cluster:
                    other_cluster._unblock_process(self)

            self.cluster.processes.remove(self)
            assert self not in self.cluster.processes, "we are in the list twice"
            self.cluster = None
Exemplo n.º 2
0
 def kill(self):
     '''Suddenly terminate the process ungracefully'''
     
     assert self.process is not None
     assert self.check() is None, 'When asked to kill a process it was already stopped!'
     
     utils.kill_process_group(self.process_group_id, shutdown_grace=0)
     self.running = False
     self.close()
Exemplo n.º 3
0
 def kill(self):
     '''Suddenly terminate the process ungracefully'''
     
     assert self.process is not None
     assert self.check() is None, 'When asked to kill a process it was already stopped!'
     
     utils.kill_process_group(self.pid, shutdown_grace=0)
     self.returncode = self.process.wait()
     self.processs = None
     self.killed = True
     self.stop()
Exemplo n.º 4
0
    def kill(self):
        """Suddenly terminate the process ungracefully"""

        assert self.process is not None
        assert self.check() is None, "When asked to kill a process it was already stopped!"

        utils.kill_process_group(self, timeout=0)
        self.returncode = self.process.wait()
        self.processs = None
        self.killed = True
        self.stop()
Exemplo n.º 5
0
 def endServer(self):
     '''Shutdown the server'''
     
     try:
         if self.__serverProcess is not None and self.__serverProcess.poll() is None:
             utils.kill_process_group(self.__serverProcess)
     except Exception: pass
     
     self.__serverProcess = None
     self.__serverOutput = None
     
     self.httpbinPort = None
     self.httpPort = None
     self.sslPort = None
Exemplo n.º 6
0
    def stop(self):
        """Gracefully shut down the server"""
        global runningServers

        if self.running:
            if self.process.poll() is None:
                utils.kill_process_group(self, timeout=20)
                self.returncode = self.process.poll()
                if self.returncode is None:
                    try:
                        self.returncode = self.process.wait()
                    except OSError:
                        sys.stderr.write(
                            "The subprocess module lost the connection to the %s %s, assuming it closed cleanly (2)\n"
                            % (self.server_type, self.name)
                        )
                        sys.stderr.flush()
                        self.returncode = 0
                assert self.returncode is not None, "%s %s failed to exit!" % (self.server_type.capitalize(), self.name)
        if self.process:
            try:
                self.returncode = self.process.wait()
            except OSError:
                sys.stderr.write(
                    "The subprocess module lost the connection to the %s %s, assuming it closed cleanly (3)\n"
                    % (self.server_type, self.name)
                )
                sys.stderr.flush()
                self.returncode = 0

        if self in runningServers:
            runningServers.remove(self)

        # - reset Resunder blocking for these ports

        self.update_routing()

        # - clean out running variables

        self.process = None
        self._cluster_port = None
        self._driver_port = None
        self._http_port = None
        self._ready_line = False
        self._log_maker = None
Exemplo n.º 7
0
    def stop(self):
        '''Gracefully shut down the server'''
        global runningServers

        if self.running:
            if self.process.poll() is None:
                utils.kill_process_group(self, timeout=20)
                self.returncode = self.process.poll()
                if self.returncode is None:
                    try:
                        self.returncode = self.process.wait()
                    except OSError:
                        sys.stderr.write(
                            'The subprocess module lost the connection to the %s %s, assuming it closed cleanly (2)\n'
                            % (self.server_type, self.name))
                        sys.stderr.flush()
                        self.returncode = 0
                assert self.returncode is not None, '%s %s failed to exit!' % (
                    self.server_type.capitalize(), self.name)
        if self.process:
            try:
                self.returncode = self.process.wait()
            except OSError:
                sys.stderr.write(
                    'The subprocess module lost the connection to the %s %s, assuming it closed cleanly (3)\n'
                    % (self.server_type, self.name))
                sys.stderr.flush()
                self.returncode = 0

        if self in runningServers:
            runningServers.remove(self)

        # - reset Resunder blocking for these ports

        self.update_routing()

        # - clean out running variables

        self.process = None
        self._cluster_port = None
        self._driver_port = None
        self._http_port = None
        self._ready_line = False
        self._log_maker = None