Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions module/config/argument/args.json
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,20 @@
"display": "hide"
}
},
"MidnightRandomDelay": {
"Enable": {
"type": "checkbox",
"value": false,
"option": [
true,
false
]
},
"MaxSeconds": {
"type": "input",
"value": 300
}
},
"Storage": {
"Storage": {
"type": "storage",
Expand Down
8 changes: 8 additions & 0 deletions module/config/argument/argument.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ Scheduler:
ServerUpdate:
value: 00:00
display: hide
Restart:
MidnightRandomDelay:
Enable:
type: checkbox
value: false
option: [ true, false ]
MaxSeconds:
value: 300
Emulator:
Serial:
value: auto
Expand Down
4 changes: 4 additions & 0 deletions module/config/config_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class GeneratedConfig:
Scheduler_FailureInterval = 120
Scheduler_ServerUpdate = '00:00'

# Group `Restart`
Restart_MidnightRandomDelay_Enable = False # True, False
Restart_MidnightRandomDelay_MaxSeconds = 300

# Group `Emulator`
Emulator_Serial = 'auto'
Emulator_PackageName = 'auto' # auto, com.bilibili.azurlane, com.YoStarEN.AzurLane, com.YoStarJP.AzurLane, com.hkmanjuu.azurlane.gp, com.bilibili.blhx.huawei, com.bilibili.blhx.honor, com.bilibili.blhx.mi, com.tencent.tmgp.bilibili.blhx, com.bilibili.blhx.baidu, com.bilibili.blhx.qihoo, com.bilibili.blhx.nearme.gamecenter, com.bilibili.blhx.vivo, com.bilibili.blhx.mz, com.bilibili.blhx.dl, com.bilibili.blhx.lenovo, com.bilibili.blhx.uc, com.bilibili.blhx.mzw, com.yiwu.blhx.yx15, com.bilibili.blhx.m4399, com.bilibili.blhx.bilibiliMove, com.hkmanjuu.azurlane.gp.mc
Expand Down
22 changes: 22 additions & 0 deletions module/config/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,28 @@
"multi": "Coalition Battle"
}
},
"Restart": {
"_info": {
"name": "Restart Settings",
"help": ""
}
},
"MidnightRandomDelay": {
"_info": {
"name": "Midnight Random Delay",
"help": ""
},
"Enable": {
"name": "Midnight Random Delay",
"help": "Enable to add a random delay before restart at midnight, reducing network load near 00:00",
"True": "Enable",
"False": "Disable"
},
"MaxSeconds": {
"name": "Max Delay (seconds)",
"help": "Maximum random delay in seconds, a random value between 0 and this will be used"
}
},
"Commission": {
"_info": {
"name": "Commission Settings",
Expand Down
22 changes: 22 additions & 0 deletions module/config/i18n/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,28 @@
"multi": "multi"
}
},
"Restart": {
"_info": {
"name": "再起動設定",
"help": ""
}
},
"MidnightRandomDelay": {
"_info": {
"name": "深夜ランダム遅延",
"help": ""
},
"Enable": {
"name": "深夜ランダム遅延",
"help": "深夜0:00付近の再起動時にランダムな遅延を追加し、ネットワーク負荷を軽減します",
"True": "有効",
"False": "無効"
},
"MaxSeconds": {
"name": "最大遅延(秒)",
"help": "ランダム遅延の最大値(秒)、0からこの値の間でランダムに決定されます"
}
},
"Commission": {
"_info": {
"name": "Commission._info.name",
Expand Down
22 changes: 22 additions & 0 deletions module/config/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,28 @@
"multi": "多队出击"
}
},
"Restart": {
"_info": {
"name": "重启设置",
"help": ""
}
},
"MidnightRandomDelay": {
"_info": {
"name": "午夜随机延迟",
"help": ""
},
"Enable": {
"name": "午夜随机延迟",
"help": "如遇半夜重启时卡网络可以尝试打开此开关,降低0:00附近的网络压力",
"True": "启用",
"False": "关闭"
},
"MaxSeconds": {
"name": "随机延迟上限",
"help": "延迟时间的最大值(秒),将在0到此值之间随机"
}
},
"Commission": {
"_info": {
"name": "委托",
Expand Down
22 changes: 22 additions & 0 deletions module/config/i18n/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,28 @@
"multi": "多隊出擊"
}
},
"Restart": {
"_info": {
"name": "重啟設定",
"help": ""
}
},
"MidnightRandomDelay": {
"_info": {
"name": "午夜隨機延遲",
"help": ""
},
"Enable": {
"name": "午夜隨機延遲",
"help": "如遇半夜重啟時卡網路可以嘗試打開此開關,降低0:00附近的網路壓力",
"True": "啟用",
"False": "關閉"
},
"MaxSeconds": {
"name": "隨機延遲上限",
"help": "延遲時間的最大值(秒),將在0到此值之間隨機"
}
},
"Commission": {
"_info": {
"name": "委託",
Expand Down
13 changes: 13 additions & 0 deletions module/handler/login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import random
from datetime import datetime
from typing import Union

import numpy as np
Expand All @@ -9,6 +11,7 @@
import module.config.server as server
from module.base.timer import Timer
from module.base.utils import color_similarity_2d, crop
from module.config.utils import server_time_offset
from module.handler.assets import *
from module.logger import logger
from module.map.assets import *
Expand Down Expand Up @@ -163,6 +166,16 @@ def app_start(self):

def app_restart(self):
logger.hr('App restart')
# Random delay when triggered at server midnight to avoid load spikes
if self.config.Restart_MidnightRandomDelay_Enable:
max_delay = self.config.Restart_MidnightRandomDelay_MaxSeconds
server_now = datetime.now() + server_time_offset()
if server_now.hour == 0 and server_now.minute < 5 and max_delay > 0:
delay = random.randint(0, max_delay)
if delay > 0:
logger.info(f'Restart at server midnight: random delay {delay}s'
f' (all tasks blocked)')
self.device.sleep(delay)
self.device.app_stop()
self.device.app_start()
self.handle_app_login()
Expand Down
2 changes: 2 additions & 0 deletions module/webui/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ def raise_exception(x=3):

def get_alas_config_listen_path(args):
for path, d in deep_iter(args, depth=3):
if not isinstance(d, dict):
continue
if d.get("display") in ["readonly", "hide"]:
continue
yield path
Expand Down