-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Restart delay #5741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Tianming-Wu
wants to merge
7
commits into
LmeSzinc:dev
Choose a base branch
from
Tianming-Wu:restart-delay
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Restart delay #5741
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6a4794e
Add restart delay at midnight
Tianming-Wu 4e80e0e
Move restart delay logic to LoginHandler Module
Tianming-Wu 7659b44
Add configuration entry for midnight restart
Tianming-Wu 38749b6
Merge branch 'LmeSzinc:master' into restart-delay
Tianming-Wu 38b7eee
Correct timezone configuration
Tianming-Wu 00ae406
Fix: guard to prevent application crash with non-dictionary type in g…
Tianming-Wu 62df292
Fix: restart midnight delay configuratoion
Tianming-Wu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
|
|
@@ -163,6 +165,18 @@ def app_start(self): | |
|
|
||
| def app_restart(self): | ||
| logger.hr('App restart') | ||
| # 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) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 需要时区换算
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 已补充时区配置 |
||
| self.device.app_stop() | ||
| self.device.app_start() | ||
| self.handle_app_login() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这怎么有三个层级的?这不对吧
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
前面生成的多余的修了(还没提交)。
这里有三个层级是因为配置里面是这样写的:
可以工作,并且语义也足够清晰。一定要改成两层的也可以改