加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
run.py 1.53 KB
一键复制 编辑 原始数据 按行查看 历史
a76yyyy 提交于 2021-06-30 00:12 . python3调试
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 Binux <roy@binux.me>
import sys
import logging
import tornado.log
from tornado.ioloop import IOLoop, PeriodicCallback
from tornado.httpserver import HTTPServer
import config
from web.app import Application
from worker import MainWorker
import sqlite3_db_task_converter
import requests
requests.packages.urllib3.disable_warnings()
if __name__ == "__main__":
if sys.getdefaultencoding() != 'utf-8':
import importlib
importlib.reload(sys)
# init logging
logger = logging.getLogger()
logger.setLevel(logging.DEBUG if config.debug else logging.INFO)
channel = logging.StreamHandler(sys.stdout)
channel.setFormatter(tornado.log.LogFormatter())
logger.addHandler(channel)
if not config.debug:
channel = logging.StreamHandler(sys.stderr)
channel.setFormatter(tornado.log.LogFormatter())
channel.setLevel(logging.WARNING)
logger.addHandler(channel)
if len(sys.argv) > 2 and sys.argv[1] == '-p' and sys.argv[2].isdigit():
port = int(sys.argv[2])
else:
port = config.port
converter = sqlite3_db_task_converter.DBconverter()
converter.ConvertNewType()
http_server = HTTPServer(Application(), xheaders=True)
http_server.bind(port, config.bind)
http_server.start()
worker = MainWorker()
PeriodicCallback(worker, config.check_task_loop).start()
worker()
logging.info("http server started on %s:%s", config.bind, port)
IOLoop.instance().start()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化