Beispiel #1
0
def mainloop():
    """ function to be used as mainloop. """
    while 1:
        try:
            time.sleep(1)
            mainhandler.handle_one()
        except KeyboardInterrupt: break
        except Exception, ex:
            handle_exception()
            globalshutdown()
            os._exit(1)
Beispiel #2
0
def mainloop():
    """ function to be used as mainloop. """
    while 1:
        try:
            time.sleep(1)
            mainhandler.handle_one()
        except KeyboardInterrupt:
            break
        except Exception, ex:
            handle_exception()
            globalshutdown()
            os._exit(1)
Beispiel #3
0
def runapiserver(port=None, ddir=None):
    """ start running the API server. needs to be called from the main thread. """
    from jsb.drivers.tornado.bot import TornadoBot
    global bot
    bot = TornadoBot(botname="api-bot")
    if port:
        try: port = int(port)
        except ValueError: pass
    else: port = 10105
    try:
         server = createserver(ddir or getdatadir())
         server.bind(port)
         logging.warn("starting API server on port %s" % port)
         server.start()
         server.io_loop.start()
    except KeyboardInterrupt: globalshutdown()
    except Exception, ex: handle_exception() ; os._exit(1)
    else: globalshutdown()
Beispiel #4
0
def runapiserver(port=None, ddir=None):
    """ start running the API server. needs to be called from the main thread. """
    from jsb.drivers.tornado.bot import TornadoBot
    global bot
    bot = TornadoBot(botname="api-bot")
    if port:
        try:
            port = int(port)
        except ValueError:
            pass
    else:
        port = 10105
    try:
        server = createserver(ddir or getdatadir())
        server.bind(port)
        logging.warn("starting API server on port %s" % port)
        server.start()
        server.io_loop.start()
    except KeyboardInterrupt:
        globalshutdown()
    except Exception, ex:
        handle_exception()
        os._exit(1)
Beispiel #5
0
    application = tornado.web.Application([(r"(/api/.*)", APIHandler)],
                                          **settings)
    return TornadoServer(application)


def runapiserver(port=None, ddir=None):
    """ start running the API server. needs to be called from the main thread. """
    from jsb.drivers.tornado.bot import TornadoBot
    global bot
    bot = TornadoBot(botname="api-bot")
    if port:
        try:
            port = int(port)
        except ValueError:
            pass
    else:
        port = 10105
    try:
        server = createserver(ddir or getdatadir())
        server.bind(port)
        logging.warn("starting API server on port %s" % port)
        server.start()
        server.io_loop.start()
    except KeyboardInterrupt:
        globalshutdown()
    except Exception, ex:
        handle_exception()
        os._exit(1)
    else:
        globalshutdown()
Beispiel #6
0
#
#

""" main loop used in jsb binairies. """

## jsb imports

from jsb.lib.eventhandler import mainhandler
from jsb.lib.exit import globalshutdown

## basic imports

import os
import time

## mainloop function

def mainloop():
    """ function to be used as mainloop. """
    while 1:
        try:
            time.sleep(1)
            mainhandler.handle_one()
        except KeyboardInterrupt: break
        except Exception, ex:
            handle_exception()
            globalshutdown()
            os._exit(1)
    globalshutdown()
    os._exit(0)