mirror of
https://github.com/xfgryujk/blivechat.git
synced 2025-03-28 21:10:49 +08:00
添加host、port配置项
This commit is contained in:
parent
60b9f81fe2
commit
c3db0a41b3
@ -49,6 +49,8 @@ def get_config():
|
||||
|
||||
class AppConfig:
|
||||
def __init__(self):
|
||||
self.host = '127.0.0.1'
|
||||
self.port = 12450
|
||||
self.database_url = 'sqlite:///data/database.db'
|
||||
self.tornado_xheaders = False
|
||||
self.loader_url = ''
|
||||
@ -78,6 +80,8 @@ class AppConfig:
|
||||
|
||||
def _load_app_config(self, config: configparser.ConfigParser):
|
||||
app_section = config['app']
|
||||
self.host = app_section.get('host', self.host)
|
||||
self.port = app_section.getint('port', fallback=self.port)
|
||||
self.database_url = app_section.get('database_url', self.database_url)
|
||||
self.tornado_xheaders = app_section.getboolean('tornado_xheaders', fallback=self.tornado_xheaders)
|
||||
self.loader_url = app_section.get('loader_url', self.loader_url)
|
||||
|
@ -2,6 +2,11 @@
|
||||
# If you want to modify the configuration, copy this file and rename it to "config.ini" and edit
|
||||
|
||||
[app]
|
||||
# 服务器监听的地址
|
||||
# The address the server listens on
|
||||
host = 127.0.0.1
|
||||
port = 12450
|
||||
|
||||
# 数据库配置,见 https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls
|
||||
# See https://docs.sqlalchemy.org/en/20/core/engines.html#database-urls
|
||||
database_url = sqlite:///data/database.db
|
||||
|
11
main.py
11
main.py
@ -53,8 +53,8 @@ def main():
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser(description='用于OBS的仿YouTube风格的bilibili直播评论栏')
|
||||
parser.add_argument('--host', help='服务器host,默认为127.0.0.1', default='127.0.0.1')
|
||||
parser.add_argument('--port', help='服务器端口,默认为12450', type=int, default=12450)
|
||||
parser.add_argument('--host', help='服务器host,默认和配置中的一样', default=None)
|
||||
parser.add_argument('--port', help='服务器端口,默认和配置中的一样', type=int, default=None)
|
||||
parser.add_argument('--debug', help='调试模式', action='store_true')
|
||||
return parser.parse_args()
|
||||
|
||||
@ -77,13 +77,18 @@ def init_logging(debug):
|
||||
|
||||
|
||||
def run_server(host, port, debug):
|
||||
cfg = config.get_config()
|
||||
if host is None:
|
||||
host = cfg.host
|
||||
if port is None:
|
||||
port = cfg.port
|
||||
|
||||
app = tornado.web.Application(
|
||||
routes,
|
||||
websocket_ping_interval=10,
|
||||
debug=debug,
|
||||
autoreload=False
|
||||
)
|
||||
cfg = config.get_config()
|
||||
try:
|
||||
app.listen(
|
||||
port,
|
||||
|
Loading…
Reference in New Issue
Block a user