Skip to content

Restart delay#5741

Open
Tianming-Wu wants to merge 7 commits into
LmeSzinc:devfrom
Tianming-Wu:restart-delay
Open

Restart delay#5741
Tianming-Wu wants to merge 7 commits into
LmeSzinc:devfrom
Tianming-Wu:restart-delay

Conversation

@Tianming-Wu

Copy link
Copy Markdown
Contributor

Alas restart the game everyday at 0:00, this will put some pressure on the server, and the game may crash several times.

This edit adds a configurable random delay for the midnight restart (does not affect restart in other cases, unless it is still within 0:00~0:05)。

The config is not exposed to user. It is in config_manual.py, as key SCHEDULER_RESTART_RANDOM_DELAY in seconds. The default value is set to 300s (5min), it might not be the best value.

@Tianming-Wu

Copy link
Copy Markdown
Contributor Author

Also it is possible to disable this feature by setting the SCHEDULER_RESTART_RANDOM_DELAY to 0.

@guoh064

guoh064 commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

凭什么要延迟启动alas😅演习怎么办

@Tianming-Wu

Copy link
Copy Markdown
Contributor Author

凭什么要延迟启动alas😅演习怎么办

除非你需要卡时间冲军衔,否则演习并没有必须在刷新之后立刻执行的需求。

这是在开发群讨论过的问题,零点大量设备重启会对黄鸡的服务器造成很大的压力。我所有设备基本上都会在午夜演习期间因为卡网重启 1~2 次。

你真的需要立刻执行可以关掉这个。

@guoh064

guoh064 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

你这样说那我的设备并不会卡重启。不应该默认大家都等,你觉得国服有问题可以只对国服生效。

@Tianming-Wu

Copy link
Copy Markdown
Contributor Author

在”重启设置“添加了设置项,默认关闭

Add settings entry in "Restart", default is off.

image

@Tianming-Wu

Copy link
Copy Markdown
Contributor Author

@LmeSzinc 催审核,至少给个意见

@LmeSzinc LmeSzinc left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

先想好怎么实现吧,纯等肯定是不接受的,一些任务不受跨天影响可以继续运行

Comment thread module/handler/login.py Outdated
Comment on lines +168 to +179
# Random delay when triggered at midnight to avoid server load spikes
# During this delay, other tasks are naturally blocked because
# Restart is the currently running task (highest priority at 0:00)
if self.config.Restart_MidnightRandomDelay_Enable:
max_delay = self.config.Restart_MidnightRandomDelay_MaxSeconds
now = datetime.now()
if now.hour == 0 and now.minute < 5 and max_delay > 0:
delay = random.randint(0, max_delay)
if delay > 0:
logger.info(f'Restart at midnight: random delay {delay}s'
f' (all tasks blocked)')
self.device.sleep(delay)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

需要时区换算

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已补充时区配置

Comment on lines +20 to +28
# Group `Restart`
Restart_Scheduler_Enable = False
Restart_Scheduler_NextRun = datetime.datetime(2020, 1, 1, 0, 0)
Restart_Scheduler_Command = 'Restart'
Restart_Scheduler_SuccessInterval = 0
Restart_Scheduler_FailureInterval = 120
Restart_Scheduler_ServerUpdate = '00:00'
Restart_MidnightRandomDelay_Enable = False # True, False
Restart_MidnightRandomDelay_MaxSeconds = 300

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这怎么有三个层级的?这不对吧

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

前面生成的多余的修了(还没提交)。

这里有三个层级是因为配置里面是这样写的:

Restart:
  MidnightRandomDelay:
    Enable:
      type: checkbox
      value: false
      option: [ true, false ]
    MaxSeconds:
      value: 300

可以工作,并且语义也足够清晰。一定要改成两层的也可以改

@LmeSzinc LmeSzinc added the feature request / 功能请求 New feature or requests label Jul 1, 2026
@Tianming-Wu

Copy link
Copy Markdown
Contributor Author

先想好怎么实现吧,纯等肯定是不接受的,一些任务不受跨天影响可以继续运行

这些任务执行的时候也会出现卡网络的现象,这个目标是解决卡网络以及零点附近游戏反复重启的问题,跨天时一并阻塞我认为属于期望的行为

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature request / 功能请求 New feature or requests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants