Skip to content

fix: add stdout startup completion signal for AstrBot Launcher - #7984

Closed
Blueteemo wants to merge 1 commit into
AstrBotDevs:masterfrom
Blueteemo:fix/issue-7982-launcher-startup-detection
Closed

fix: add stdout startup completion signal for AstrBot Launcher#7984
Blueteemo wants to merge 1 commit into
AstrBotDevs:masterfrom
Blueteemo:fix/issue-7982-launcher-startup-detection

Conversation

@Blueteemo

@Blueteemo Blueteemo commented May 3, 2026

Copy link
Copy Markdown
Contributor

问题描述

AstrBot Launcher 通过监控 Python 进程 stdout 中的 AstrBot 启动完成 来判断实例是否启动完成。但当前代码使用 logger.info("AstrBot started.") 输出启动消息,该消息走 loguru 日志通道(stderr),Launcher 无法检测到,导致 300 秒后超时 kill 进程。

修复方案

core_lifecycle.pystart() 方法中添加 print("AstrBot 启动完成", flush=True),将启动完成信号输出到 stdout。

关联 Issue

Fixes #7982

Summary by Sourcery

Bug Fixes:

  • Emit a dedicated startup completion signal via stdout in addition to the existing log message to prevent launcher timeout when monitoring process readiness via standard output.

@auto-assign
auto-assign Bot requested review from Raven95676 and Soulter May 3, 2026 19:12
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 3, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • Since this print is intentionally bypassing the logger for the launcher’s stdout contract, consider adding a short comment explaining that it’s a startup completion signal consumed by AstrBot Launcher so future refactors don’t remove or redirect it accidentally.
  • To avoid potential confusion around mixed languages in startup messages, consider aligning the print text with any existing constant or clearly defined protocol string used by the launcher, or centralizing it as a constant so both sides rely on the same value.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- Since this `print` is intentionally bypassing the logger for the launcher’s stdout contract, consider adding a short comment explaining that it’s a startup completion signal consumed by AstrBot Launcher so future refactors don’t remove or redirect it accidentally.
- To avoid potential confusion around mixed languages in startup messages, consider aligning the `print` text with any existing constant or clearly defined protocol string used by the launcher, or centralizing it as a constant so both sides rely on the same value.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@dosubot dosubot Bot added the area:core The bug / feature is about astrbot's core, backend label May 3, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds a print statement to signal the completion of the AstrBot startup process. A review comment points out that since background tasks are initialized asynchronously in the _load method, the startup signal might be printed before these tasks have actually begun. It is suggested to include await asyncio.sleep(0) before the print statement to ensure the event loop has an opportunity to start the background tasks.

Comment thread astrbot/core/core_lifecycle.py
@Raven95676

Copy link
Copy Markdown
Member

您好,AstrBot Launcher已在v0.3.3版本适配了新的日志行为。

另外我这边复核了一下AstrBot当前代码,log.py中的loguru sink已显式配置为sys.stdout,因此并不存在因stderr导致Launcher无法检测启动完成的问题。

@Blueteemo Blueteemo closed this May 4, 2026
@Blueteemo
Blueteemo deleted the fix/issue-7982-launcher-startup-detection branch May 4, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]实例已经启动,但是AstrBot Launcher并没有识别到

2 participants