fix(restart): send completion notice after channel is ready and unify runtime keys

This commit is contained in:
imfondof
2026-04-04 02:21:42 +08:00
committed by Xubin Ren
parent a05f83da89
commit ba7c07ccf2
4 changed files with 156 additions and 6 deletions
+3
View File
@@ -9,6 +9,7 @@ import sys
from nanobot import __version__
from nanobot.bus.events import OutboundMessage
from nanobot.command.router import CommandContext, CommandRouter
from nanobot.config.runtime_keys import RESTART_NOTIFY_CHANNEL_ENV, RESTART_NOTIFY_CHAT_ID_ENV
from nanobot.utils.helpers import build_status_content
@@ -35,6 +36,8 @@ async def cmd_stop(ctx: CommandContext) -> OutboundMessage:
async def cmd_restart(ctx: CommandContext) -> OutboundMessage:
"""Restart the process in-place via os.execv."""
msg = ctx.msg
os.environ[RESTART_NOTIFY_CHANNEL_ENV] = msg.channel
os.environ[RESTART_NOTIFY_CHAT_ID_ENV] = msg.chat_id
async def _do_restart():
await asyncio.sleep(1)