def ensure_on():
    """
    Start the DbServer if it is off
    """
    if get_status() == 'not-running':
        if config.dbserver.multi_user:
            sys.exit('Please start the DbServer: '
                     'see the documentation for details')
        # otherwise start the DbServer automatically; NB: I tried to use
        # multiprocessing.Process(target=run_server).start() and apparently
        # it works, but then run-demos.sh hangs after the end of the first
        # calculation, but only if the DbServer is started by oq engine (!?)
        subprocess.Popen([sys.executable, '-m', 'openquake.server.dbserver',
                          '-l', 'INFO'])

        # wait for the dbserver to start
        waiting_seconds = 30
        while get_status() == 'not-running':
            if waiting_seconds == 0:
                sys.exit('The DbServer cannot be started after 30 seconds. '
                         'Please check the configuration')
            time.sleep(1)
            waiting_seconds -= 1
def ensure_on ( ) : if get_status ( ) == 'not-running' : if config . dbserver . multi_user : sys . exit ( 'Please start the DbServer: ' 'see the documentation for details' ) subprocess . Popen ( [ sys . executable , '-m' , 'openquake.server.dbserver' , '-l' , 'INFO' ] ) waiting_seconds = 30 while get_status ( ) == 'not-running' : if waiting_seconds == 0 : sys . exit ( 'The DbServer cannot be started after 30 seconds. ' 'Please check the configuration' ) time . sleep ( 1 ) waiting_seconds -= 1
Start the DbServer if it is off