fix: use sys.stdin.isatty() for non-interactive detection

Replace redundant ASTRBOT_SYSTEMD environment variable checks with
sys.stdin.isatty() for detecting non-interactive environments.
The DashboardManager.ensure_installed() already handles this internally,
so the outer ASTRBOT_SYSTEMD checks were unnecessary.
This commit is contained in:
LIghtJUNction
2026-03-23 03:00:26 +08:00
parent d6f74a8493
commit 1d2469f0ae
2 changed files with 2 additions and 8 deletions

View File

@@ -138,11 +138,7 @@ async def initialize_astrbot(
default=True,
)
):
# 避免在 systemd 模式下因等待输入而阻塞
if os.environ.get("ASTRBOT_SYSTEMD") == "1":
click.echo("Systemd detected: Skipping dashboard check.")
else:
await DashboardManager().ensure_installed(astrbot_root)
await DashboardManager().ensure_installed(astrbot_root)
else:
click.echo("你可以使用在线面版(需支持配置后端)来控制。")

View File

@@ -93,9 +93,7 @@ async def run_astrbot(astrbot_root: Path) -> None:
os.environ.get("ASTRBOT_DASHBOARD_ENABLE", os.environ.get("DASHBOARD_ENABLE"))
== "True"
):
# Avoid blocking when running under systemd by waiting for input
if os.environ.get("ASTRBOT_SYSTEMD") != "1":
await DashboardManager().ensure_installed(astrbot_root)
await DashboardManager().ensure_installed(astrbot_root)
log_broker = LogBroker()
LogManager.set_queue_handler(logger, log_broker)