qcfractal/postgres_harness.py
def start(self) -> Any:
        """
        Starts a PostgreSQL server based off the current configuration parameters. The server must be initialized
        and the configured port open.
        """

        self._check_psql()

        # Startup the server
        self.logger("Starting the database:")

        if is_port_open(self.config.database.host, self.config.database.port):
            self.logger("Service currently running the configured port, current_status:\n")
            status = self.pg_ctl(["status"])

            # If status is ok, exit is 0
            if status["retcode"] != 0:
                raise ValueError(
                    f"A process is already running on 'port:{self.config.database.port}` that is not associated with the PostgreSQL instance at `location:{self.config.database.directory}.`"
                    "\nThis often happens when two PostgreSQL databases are attempted to run on the same port."
                    "\nEither shut down the other PostgreSQL database or change the `qcfractal-server init --db-port`."
                    "\nStopping."
                )

            if not self.is_alive():
                raise ValueError(f"PostgreSQL is running, but cannot connect to the default port.")

            self.logger("Found running PostgreSQL instance with correct configuration.")

        else:
            start_status = self.pg_ctl(
                ["-l", str(self.config.database_path / self.config.database.logfile), "start"]
            )  # yapf: disable

            if not (("server started" in start_status["stdout"]) or ("server starting" in start_status["stdout"])):
                raise ValueError(f"Could not start the PostgreSQL server. Error below:\n\n{start_status['stderr']}")

            # Check that we are alive
            for x in range(10):
                if self.is_alive():
                    break
                else:
                    time.sleep(0.1)
            else:
                raise ValueError(
                    f"Could not connect to the server after booting. Boot log:\n\n{start_status['stderr']}"
                )

            self.logger("PostgreSQL successfully started in a background process, current_status:\n")
            if not self.quiet:
                self._run([shutil.which("pg_ctl"), "-D", str(self.config.database_path), "status"])  # yapf: disable

        return True

        Starts a PostgreSQL server based off the current configuration parameters. The server must be initialized
        and the configured port open.
        
Starts a PostgreSQL server based off the current configuration parameters. The server must be initialized
and the configured port open.
Starts a PostgreSQL server based off the current configuration parameters . The server must be initialized and the configured port open .
def start(self) -> Any:
        self._check_psql()
        self.logger("Starting the database:")
        if is_port_open(self.config.database.host, self.config.database.port):
            self.logger("Service currently running the configured port, current_status:\n")
            status = self.pg_ctl(["status"])
            if status["retcode"] != 0:
                raise ValueError(
                    f"A process is already running on 'port:{self.config.database.port}` that is not associated with the PostgreSQL instance at `location:{self.config.database.directory}.`"
                    "\nThis often happens when two PostgreSQL databases are attempted to run on the same port."
                    "\nEither shut down the other PostgreSQL database or change the `qcfractal-server init --db-port`."
                    "\nStopping."
                )
            if not self.is_alive():
                raise ValueError(f"PostgreSQL is running, but cannot connect to the default port.")
            self.logger("Found running PostgreSQL instance with correct configuration.")
        else:
            start_status = self.pg_ctl(
                ["-l", str(self.config.database_path / self.config.database.logfile), "start"]
            )  
            if not (("server started" in start_status["stdout"]) or ("server starting" in start_status["stdout"])):
                raise ValueError(f"Could not start the PostgreSQL server. Error below:\n\n{start_status['stderr']}")
            for x in range(10):
                if self.is_alive():
                    break
                else:
                    time.sleep(0.1)
            else:
                raise ValueError(
                    f"Could not connect to the server after booting. Boot log:\n\n{start_status['stderr']}"
                )
            self.logger("PostgreSQL successfully started in a background process, current_status:\n")
            if not self.quiet:
                self._run([shutil.which("pg_ctl"), "-D", str(self.config.database_path), "status"])  
        return True
def start ( self ) -> Any : self . _check_psql ( ) self . logger ( "Starting the database:" ) if is_port_open ( self . config . database . host , self . config . database . port ) : self . logger ( "Service currently running the configured port, current_status:\n" ) status = self . pg_ctl ( [ "status" ] ) if status [ "retcode" ] != 0 : raise ValueError ( f"A process is already running on 'port:{self.config.database.port}` that is not associated with the PostgreSQL instance at `location:{self.config.database.directory}.`" "\nThis often happens when two PostgreSQL databases are attempted to run on the same port." "\nEither shut down the other PostgreSQL database or change the `qcfractal-server init --db-port`." "\nStopping." ) if not self . is_alive ( ) : raise ValueError ( f"PostgreSQL is running, but cannot connect to the default port." ) self . logger ( "Found running PostgreSQL instance with correct configuration." ) else : start_status = self . pg_ctl ( [ "-l" , str ( self . config . database_path / self . config . database . logfile ) , "start" ] ) if not ( ( "server started" in start_status [ "stdout" ] ) or ( "server starting" in start_status [ "stdout" ] ) ) : raise ValueError ( f"Could not start the PostgreSQL server. Error below:\n\n{start_status['stderr']}" ) for x in range ( 10 ) : if self . is_alive ( ) : break else : time . sleep ( 0.1 ) else : raise ValueError ( f"Could not connect to the server after booting. Boot log:\n\n{start_status['stderr']}" ) self . logger ( "PostgreSQL successfully started in a background process, current_status:\n" ) if not self . quiet : self . _run ( [ shutil . which ( "pg_ctl" ) , "-D" , str ( self . config . database_path ) , "status" ] ) return True
Starts a PostgreSQL server based off the current configuration parameters.
Starts a PostgreSQL server based off the current configuration parameters .
"""
        Starts a PostgreSQL server based off the current configuration parameters. The server must be initialized
        and the configured port open.
        """ # Startup the server # If status is ok, exit is 0 # yapf: disable # Check that we are alive # yapf: disable
self