def _run_server_as_subprocess():
    args = sys.argv[2:]
    # pass arguments
    options, remainder = getopt.getopt(args, '', ['debug', 'reload', 'host=', 'port=', 'server=', 
                                                  'baseurl=', 'runtimepath='])
    host = 'localhost'
    port = 8080 
    debug = True
    reloader = False
    server = 'kokoro'
    runtime_path = '.runtime/'
    base_url = '/'
    for opt, arg in options:
        if opt[0:2] == '--':
            opt = opt[2:]
        if opt == 'debug':
            debug = True
        elif opt == 'reload':
            reloader = True
        elif opt == 'host':
            host = arg
        elif opt == 'port':
            port = arg
        elif opt == 'server':
            server = arg
        elif opt == 'runtimepath':
            runtime_path = arg
        elif opt == 'baseurl':
            base_url = arg
    SCRIPT_PATH = os.path.abspath(__file__)
    RUN_COMMAND = '%s %s' %(sys.executable, SCRIPT_PATH)
    ARGUMENTS = 'run_server_once --host=%s --port=%d --server=%s --baseurl=%s --runtimepath=%s' %(host, port, server, base_url, runtime_path)
    if reloader:
        ARGUMENTS += ' --reload'
    if debug:
        ARGUMENTS += ' --debug'
    RUN_COMMAND = RUN_COMMAND + ' ' + ARGUMENTS
    if hasattr(os, 'setsid'):
        return subprocess.Popen(RUN_COMMAND, shell=True, preexec_fn=os.setsid)
    else:
        return subprocess.Popen(RUN_COMMAND, shell=True)
dataset/ETHPy150Open goFrendiAsgard/kokoropy/rossian.py/_run_server_as_subprocess/original