mirror of
https://github.com/mikumifa/biliTickerBuy.git
synced 2026-11-18 06:23:16 -08:00
Added BTB_NTP_SERVERS ENV
This commit is contained in:
1 parent
bacceb8426
commit
aac80738fd
3 files changed
+15
-7
No files matched your search
+4
-3
@@ -4,16 +4,17 @@ services:
|
||||
image: bilitickerbuy
|
||||
container_name: bilitickerbuy_container
|
||||
ports:
|
||||
- "7860:7860" # 默认暴露20个端口,范围可按需修改
|
||||
- "7860:7860"
|
||||
environment:
|
||||
- GRADIO_SERVER_PORT=7860
|
||||
- GRADIO_NUM_PORTS=100 # 不小于暴露的端口数量
|
||||
- GRADIO_NUM_PORTS=100
|
||||
# 如果从远端 IP、域名或反向代理访问,请设置为浏览器访问时使用的外部地址
|
||||
# 例如:http://your-server-ip:7860 或 https://your-domain.example
|
||||
- BTB_ROOT_PATH=${BTB_ROOT_PATH:-}
|
||||
|
||||
# 可在此添加环境变量使得高级设置持久化,避免每次启动容器后都需要在前端重新配置
|
||||
# (设置后网页前端仍会显示为空值,但在开始抢票时会使用这些环境变量的值)
|
||||
# - BTB_HTTPS_PROXYS=http://127.0.1:8080,socks5://127.0.1:1080
|
||||
# - BTB_HTTPS_PROXYS=http://127.0.0.1:8080,socks5://127.0.0.1:1080
|
||||
# - BTB_PUSHPLUSTOKEN=your_pushplus_token
|
||||
# - BTB_BARKTOKEN=your_bark_token
|
||||
# - BTB_NTFY_URL=https://ntfy.sh/topic
|
||||
|
||||
+4
-3
@@ -13,6 +13,7 @@ DEFAULT_NTP_SERVERS = (
|
||||
"ntp.aliyun.com",
|
||||
"ntp.tencent.com",
|
||||
"cn.ntp.org.cn",
|
||||
"time.cloudflare.com",
|
||||
)
|
||||
|
||||
|
||||
@@ -50,10 +51,10 @@ class BiliTimeCheck:
|
||||
|
||||
|
||||
class TimeUtil:
|
||||
# NTP服务器默认为ntp.aliyun.com, 可根据实际情况修改
|
||||
# NTP服务器默认来自DEFAULT_NTP_SERVERS, 可根据实际情况修改
|
||||
def __init__(
|
||||
self,
|
||||
_ntp_server="ntp.aliyun.com",
|
||||
_ntp_server = None,
|
||||
*,
|
||||
ntp_servers: list[str] | tuple[str, ...] | None = None,
|
||||
bili_time_url: str = "https://show.bilibili.com/api/ticket/project/listV2",
|
||||
@@ -63,7 +64,7 @@ class TimeUtil:
|
||||
if ntp_servers is not None
|
||||
else (
|
||||
DEFAULT_NTP_SERVERS
|
||||
if _ntp_server == "ntp.aliyun.com"
|
||||
if _ntp_server is None
|
||||
else (_ntp_server,)
|
||||
)
|
||||
)
|
||||
|
||||
+7
-1
@@ -84,8 +84,14 @@ def set_main_request(request):
|
||||
global main_request
|
||||
main_request = request
|
||||
|
||||
if os.environ.get("BTB_NTP_SERVERS"):
|
||||
ntp_servers = os.environ.get("BTB_NTP_SERVERS").split(",")
|
||||
time_service = TimeUtil(ntp_servers=ntp_servers)
|
||||
else:
|
||||
time_service = TimeUtil()
|
||||
|
||||
|
||||
|
||||
time_service = TimeUtil()
|
||||
if os.environ.get("BTB_SKIP_INITIAL_TIME_SYNC") == "1":
|
||||
time_service.set_timeoffset("0")
|
||||
else:
|
||||
|
||||
Reference in new issue
Block a user