Skip to content

Commit

Permalink
feat:open_service
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Oct 18, 2024
1 parent 42a0113 commit a56c19d
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
1 change: 1 addition & 0 deletions config/config.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[Settings]
open_service = True
open_update = True
open_use_old_result = True
source_file = config/demo.txt
Expand Down
3 changes: 2 additions & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
| 配置项 | 默认值 | 描述 |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| open_update | True | 开启更新,若关闭则只运行结果页面服务 |
| open_service | True | 开启页面服务,用于控制是否启动结果页面服务;如果使用青龙等平台部署,有专门设定的定时任务,需要更新完成后停止运行,可以关闭该功能 |
| open_update | True | 开启更新,用于控制是否更新接口,若关闭则所有工作模式(获取接口和测速)均停止 |
| open_use_old_result | True | 开启使用历史更新结果(包含模板与结果文件的接口),合并至本次更新中 |
| open_driver | True | 开启浏览器运行,若更新无数据可开启此模式,较消耗性能 |
| open_proxy | False | 开启代理,自动获取免费可用代理,若更新无数据可开启此模式 |
Expand Down
1 change: 1 addition & 0 deletions docs/config_en.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
| Configuration Item | Default Value | Description |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| open_service | True | Enable page service, used to control whether to start the result page service; if deployed on platforms like Qinglong with dedicated scheduled tasks, the function can be turned off after updates are completed and the task is stopped |
| open_update | True | Enable updates, if disabled then only the result page service is run |
| open_use_old_result | True | Enable the use of historical update results (including the interface for template and result files) and merge them into the current update |
| open_driver | True | Enable browser execution, If there are no updates, this mode can be enabled, which consumes more performance |
Expand Down
21 changes: 14 additions & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,25 @@ async def main(self):
f"Update completed! Total time spent: {total_time}. Please check the {user_final_file} file!"
)
if self.run_ui:
open_service = config.getboolean(
"Settings", "open_service", fallback=True
)
service_tip = ", 可使用以下链接观看直播:" if open_service else ""
tip = (
"服务启动成功, 可使用以下链接观看直播:"
if config.getboolean("Settings", "open_update", fallback=True)
f"服务启动成功{service_tip}"
if open_service
and config.getboolean("Settings", "open_update", fallback=True)
== False
else f"更新完成, 耗时: {total_time}, 请检查{user_final_file}文件, 可使用以下链接观看直播:"
else f"更新完成, 耗时: {total_time}, 请检查{user_final_file}文件{service_tip}"
)
self.update_progress(
tip,
100,
True,
url=f"{get_ip_address()}",
url=f"{get_ip_address()}" if open_service else None,
)
run_app()
if open_service:
run_service()
except asyncio.exceptions.CancelledError:
print("Update cancelled!")
finally:
Expand Down Expand Up @@ -264,7 +270,7 @@ def scheduled_task():
loop.run_until_complete(update_source.start())


def run_app():
def run_service():
if not os.environ.get("GITHUB_ACTIONS"):
ip_address = get_ip_address()
print(f"You can use this url to watch the live stream: {ip_address}")
Expand All @@ -276,4 +282,5 @@ def run_app():
if __name__ == "__main__":
if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1] == "scheduled_task"):
scheduled_task()
run_app()
if config.getboolean("Settings", "open_service", fallback=True):
run_service()

0 comments on commit a56c19d

Please sign in to comment.