Пример #1
0
def run_server_once():
    
    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
    kokoropy.kokoro_init(debug=debug, port=port, reloader=reloader,
                         host=host, server=server, base_url=base_url, runtime_path=runtime_path)
Пример #2
0
def main_process(host, port, debug, reloader, server, app_directory, base_url, runtime_path):
    import kokoropy    
    application_path = os.path.join(PWD, app_directory)
    kokoropy.kokoro_init(application_path=application_path, debug=debug, port=port, reloader=reloader, 
                         host=host, server=server, base_url=base_url, runtime_path=runtime_path) 
Пример #3
0
import os, sys
import kokoropy

PWD = './'
if os.path.dirname(__file__) == '':
    PWD = os.path.abspath(os.getcwd())
else:
    PWD = os.path.dirname(os.path.abspath(__file__))
os.chdir(PWD)
if PWD not in sys.path:
    sys.path.append(PWD)

application = kokoropy.kokoro_init(run = False, 
                                   runtime_path = '.heroku_runtime/', 
                                   base_url = '/')

if __name__ == '__main__':
    print "=== Run the server ==="
    processor_count = 1
    try:
        import multiprocessing
        processor_count = multiprocessing.cpu_count()
    except (ImportError,NotImplementedError):
        processor_count = 1
    kokoropy.run(app=application, server='gunicorn', host = '0.0.0.0', port = os.environ.get('PORT', 5000), workers = processor_count*2+1)
Пример #4
0
import os, sys
import kokoropy

PWD = './'
if os.path.dirname(__file__) == '':
    PWD = os.path.abspath(os.getcwd())
else:
    PWD = os.path.dirname(os.path.abspath(__file__))
os.chdir(PWD)
if PWD not in sys.path:
    sys.path.append(PWD)

APP_DIRECTORY = 'applications'
APPLICATION_PATH = os.path.join(PWD, APP_DIRECTORY)
application = kokoropy.kokoro_init(application_path = APPLICATION_PATH, run = False, 
                                   runtime_path = '.heroku_runtime/', 
                                   base_url = '/')

if __name__ == '__main__':
    print "=== Run the server ==="
    processor_count = 1
    try:
        import multiprocessing
        processor_count = multiprocessing.cpu_count()
    except (ImportError,NotImplementedError):
        processor_count = 1
    kokoropy.run(app=application, server='gunicorn', host = '0.0.0.0', port = os.environ.get('PORT', 5000), workers = processor_count*2+1)