代码拉取完成,页面将自动刷新
同步操作将从 qd-today/qd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 Binux <roy@binux.me>
from libs.log import Log
import tornado.log
import sys
import platform
import config
from db 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 = Log().getlogger()
logger_Qiandao = Log('qiandao.run').getlogger()
if config.debug:
import logging
channel = logging.StreamHandler(sys.stderr)
channel.setFormatter(tornado.log.LogFormatter())
channel.setLevel(logging.WARNING)
logger_Qiandao.addHandler(channel)
if not config.accesslog:
tornado.log.access_log.disabled = True
else:
tornado.log.access_log = Log('tornado.access').getlogger()
# tornado.log.app_log = Log('tornado.application').getlogger()
if len(sys.argv) > 2 and sys.argv[1] == '-p' and sys.argv[2].isdigit():
port = int(sys.argv[2])
else:
port = config.port
if platform.system() == 'Windows':
config.multiprocess = False
if config.multiprocess and config.autoreload:
config.autoreload = False
if config.db_type == 'sqlite3':
import sqlite3_db as db
else:
import db
class DB(object):
def __init__(self) -> None:
self.user = db.UserDB()
self.tpl = db.TPLDB()
self.task = db.TaskDB()
self.tasklog = db.TaskLogDB()
self.push_request = db.PRDB()
self.redis = db.RedisDB()
self.site = db.SiteDB()
self.pubtpl = db.PubTplDB()
self.notepad = db.NotePadDB()
def close(self):
self.user.close()
self.tpl.close()
self.task.close()
self.tasklog.close()
self.push_request.close()
self.redis.close()
self.site.close()
self.pubtpl.close()
self.notepad.close()
database = DB()
try:
from web.app import Application
converter = sqlite3_db_task_converter.DBconverter()
converter.ConvertNewType(DB())
converter.db.close()
from tornado.httpserver import HTTPServer
http_server = HTTPServer(Application(database), xheaders=True)
http_server.bind(port, config.bind)
if config.multiprocess:
http_server.start(num_processes=0)
else:
http_server.start()
from worker import MainWorker
from tornado.ioloop import IOLoop, PeriodicCallback
worker = MainWorker(database)
PeriodicCallback(worker, config.check_task_loop).start()
worker()
logger_Qiandao.info("Http Server started on %s:%s", config.bind, port)
IOLoop.instance().start()
except KeyboardInterrupt :
logger_Qiandao.info("Http Server is being manually interrupted... ")
database.close()
logger_Qiandao.info("Http Server is ended. ")
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。