Beispiel #1
0
from app import apfell, dbloop, apfell_db, db_objects, use_ssl, listen_port, listen_ip, ssl_cert_path, ssl_key_path, keep_logs
import asyncio
import ssl
from app.api.rabbitmq_api import start_listening

if __name__ == "__main__":
    try:
        asyncio.set_event_loop(dbloop)
        if use_ssl:
            context = ssl.create_default_context(
                purpose=ssl.Purpose.CLIENT_AUTH)
            context.load_cert_chain(ssl_cert_path, keyfile=ssl_key_path)
            server = apfell.create_server(host=listen_ip,
                                          port=listen_port,
                                          ssl=context,
                                          debug=False,
                                          return_asyncio_server=True,
                                          access_log=keep_logs)
        else:
            server = apfell.create_server(host=listen_ip,
                                          port=listen_port,
                                          debug=False,
                                          return_asyncio_server=True,
                                          access_log=keep_logs)
        loop = asyncio.get_event_loop()
        task = asyncio.ensure_future(server, loop=dbloop)
        task2 = asyncio.ensure_future(start_listening(), loop=dbloop)

        # thanks to some awesome people at the sanic community forums,
        # we can now detect when the bound port is already in use
        def callback(fut):
Beispiel #2
0
from app import apfell, dbloop, apfell_db, db_objects, use_ssl, listen_port, listen_ip, ssl_cert_path, ssl_key_path
import asyncio
import ssl

if __name__ == "__main__":
    asyncio.set_event_loop(dbloop)
    if use_ssl:
        context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
        context.load_cert_chain(ssl_cert_path, keyfile=ssl_key_path)
        server = apfell.create_server(host=listen_ip,
                                      port=listen_port,
                                      ssl=context)
    else:
        server = apfell.create_server(host=listen_ip, port=listen_port)
    loop = asyncio.get_event_loop()
    task = asyncio.ensure_future(server)
    db_objects.database.allow_sync = True  # raise AssertionError on ANY sync call, needs to be worked out though
    try:
        loop.run_until_complete(apfell_db.connect_async(loop=dbloop))
        loop.run_forever()
    except:
        loop.stop()
Beispiel #3
0
from app import apfell, dbloop, apfell_db, db_objects
import asyncio

if __name__ == "__main__":
    asyncio.set_event_loop(dbloop)
    server = apfell.create_server(host='0.0.0.0', port=80)
    loop = asyncio.get_event_loop()
    task = asyncio.ensure_future(server)
    db_objects.database.allow_sync = True  # raise AssertionError on ANY sync call
    try:
        loop.run_until_complete(apfell_db.connect_async(loop=dbloop))
        loop.run_forever()
    except:
        loop.stop()

Beispiel #4
0
from app import apfell, dbloop, apfell_db, db_objects, use_ssl, listen_port, listen_ip, ssl_cert_path, ssl_key_path
import asyncio
import ssl
import logging

if __name__ == "__main__":
    asyncio.set_event_loop(dbloop)
    if use_ssl:
        context = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
        context.load_cert_chain(ssl_cert_path, keyfile=ssl_key_path)
        server = apfell.create_server(host=listen_ip,
                                      port=listen_port,
                                      ssl=context,
                                      debug=False)
    else:
        server = apfell.create_server(host=listen_ip,
                                      port=listen_port,
                                      debug=False)
    loop = asyncio.get_event_loop()
    task = asyncio.ensure_future(server)

    # thanks to some awesome people at the sanic community forums,
    # we can now detect when the bound port is already in use
    def callback(fut):
        try:
            fetch_count = fut.result()
        except OSError as e:
            print("probably the port set is being used")
            fut.get_loop().stop()

    task.add_done_callback(callback)
Beispiel #5
0
from app import apfell, dbloop, apfell_db, db_objects, use_ssl, listen_port, listen_ip, ssl_cert_path, ssl_key_path
import asyncio
import ssl
import logging
from app.api.rabbitmq_api import start_listening

if __name__ == "__main__":
    try:
        asyncio.set_event_loop(dbloop)
        if use_ssl:
            context = ssl.create_default_context(
                purpose=ssl.Purpose.CLIENT_AUTH)
            context.load_cert_chain(ssl_cert_path, keyfile=ssl_key_path)
            server = apfell.create_server(host=listen_ip,
                                          port=listen_port,
                                          ssl=context,
                                          debug=False,
                                          return_asyncio_server=True)
        else:
            server = apfell.create_server(host=listen_ip,
                                          port=listen_port,
                                          debug=False,
                                          return_asyncio_server=True)
        loop = asyncio.get_event_loop()
        task = asyncio.ensure_future(server, loop=dbloop)
        task2 = asyncio.ensure_future(start_listening(), loop=dbloop)

        # thanks to some awesome people at the sanic community forums,
        # we can now detect when the bound port is already in use
        def callback(fut):
            try: