Initialize AstrBot
()
| 60 | |
| 61 | @click.command() |
| 62 | def 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}") |
nothing calls this directly
no test coverage detected