예제 #1
0
파일: init.py 프로젝트: tszho-t/v2-ui-plus
                if request.headers.get("X-Requested-With") == "XMLHttpRequest":
                    return jsonify(
                        Msg(
                            False,
                            gettext(
                                "You has been logout, please refresh this page and login again."
                            ),
                        ))
                else:
                    return redirect(url_for("base.index"))


@app.errorhandler(500)
def error_handle(e):
    from base.models import Msg

    logging.warning(e)
    response = jsonify(Msg(False, str(e)))
    response.status_code = 200
    return response


init_windows()
init_logging()
init_db()
init_app()
init_common_context()
init_bps()
init_v2_jobs()
start_schedule()
예제 #2
0
파일: v2-node.py 프로젝트: nerozhu/v2-ui
        else:
            logging.debug("[I] Successfully started.")
        logging.debug("%s %s" % (result[0], result[1]))
    except Exception as e:
        logging.error("[E] %s" % str(e))
    finally:
        logging.debug("[I] Done.")


if __name__ == "__main__":
    logging.basicConfig(
        filename='/etc/v2-node/v2-node.log',
        datefmt='%Y-%m-%d %H:%M:%S',
        format='%(asctime)s-%(name)s-%(levelname)s-%(message)s',
        level=logging.WARN)
    schedule_util.start_schedule()
    svr = socket(AF_INET, SOCK_STREAM)
    try:
        svr.bind(("0.0.0.0", 40001))
    except OSError as e:
        svr.setsockopt(SOL_SOCKET, SO_REUSEPORT, 1)
        svr.bind(("0.0.0.0", 40001))
    svr.listen(5)
    logging.error("[I] Listening on 40001...")
    while True:
        try:
            conn, addr = svr.accept()
            logging.debug("[D] Received connection from: %s:%d" % addr)
            header_len = conn.recv(4)
            if header_len:
                logging.debug("[D] Ready to receive data.")