MCPcopy
hub / github.com/AstrBotDevs/AstrBot / init

Function init

astrbot/cli/commands/cmd_init.py:62–82  ·  view source on GitHub ↗

Initialize AstrBot

()

Source from the content-addressed store, hash-verified

60
61@click.command()
62def init() -> None:
63 """Initialize AstrBot"""
64 from ..utils import get_astrbot_root
65
66 click.echo("Initializing AstrBot...")
67
68 astrbot_root = get_astrbot_root()
69 lock_file = astrbot_root / "astrbot.lock"
70 lock = FileLock(lock_file, timeout=5)
71
72 try:
73 with lock.acquire():
74 asyncio.run(initialize_astrbot(astrbot_root))
75 click.echo("Done! You can now run 'astrbot run' to start AstrBot")
76 except Timeout:
77 raise click.ClickException(
78 "Cannot acquire lock file. Please check if another instance is running"
79 )
80
81 except Exception as e:
82 raise click.ClickException(f"Initialization failed: {e!s}")

Callers

nothing calls this directly

Calls 4

initialize_astrbotFunction · 0.85
get_astrbot_rootFunction · 0.50
acquireMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected