Skip to content

gateway_cmd

gateway_cmd

diapason gateway start|stop|status|logs — multi-channel gateway management.

Functions:

gateway

gateway() -> None

Manage the Diapason multi-channel gateway.

Source code in src/diapason/cli/gateway_cmd.py
@click.group()
def gateway() -> None:
    """Manage the Diapason multi-channel gateway."""

start

start(install: bool) -> None

Start the gateway daemon.

Source code in src/diapason/cli/gateway_cmd.py
@gateway.command()
@click.option(
    "--install",
    is_flag=True,
    help="Generate and enable systemd/launchd service",
)
def start(install: bool) -> None:
    """Start the gateway daemon."""
    if install:
        import platform as plat

        from diapason.daemon.service import (
            generate_launchd_plist,
            generate_systemd_service,
        )

        if plat.system() == "Darwin":
            plist_path = Path.home() / "Library/LaunchAgents/com.diapason.gateway.plist"
            generate_launchd_plist(plist_path)
            click.echo(f"Wrote {plist_path}")
            subprocess.run(
                ["launchctl", "load", str(plist_path)],
                check=False,
            )
        else:
            service_path = Path.home() / ".config/systemd/user/diapason-gateway.service"
            generate_systemd_service(service_path)
            click.echo(f"Wrote {service_path}")
            subprocess.run(
                ["systemctl", "--user", "daemon-reload"],
                check=False,
            )
            subprocess.run(
                ["systemctl", "--user", "enable", "--now", "diapason-gateway"],
                check=False,
            )
    else:
        click.echo("Starting Diapason gateway (foreground)...")
        click.echo("Gateway started. Press Ctrl+C to stop.")

stop

stop() -> None

Stop the gateway daemon.

Source code in src/diapason/cli/gateway_cmd.py
@gateway.command()
def stop() -> None:
    """Stop the gateway daemon."""
    import platform as plat

    if plat.system() == "Darwin":
        subprocess.run(
            ["launchctl", "remove", "com.diapason.gateway"],
            check=False,
        )
    else:
        subprocess.run(
            ["systemctl", "--user", "stop", "diapason-gateway"],
            check=False,
        )
    click.echo("Gateway stopped.")

status

status() -> None

Check gateway status.

Source code in src/diapason/cli/gateway_cmd.py
@gateway.command()
def status() -> None:
    """Check gateway status."""
    import platform as plat

    if plat.system() == "Darwin":
        subprocess.run(
            ["launchctl", "list", "com.diapason.gateway"],
            check=False,
        )
    else:
        subprocess.run(
            ["systemctl", "--user", "status", "diapason-gateway"],
            check=False,
        )

logs

logs() -> None

View gateway logs.

Source code in src/diapason/cli/gateway_cmd.py
@gateway.command()
def logs() -> None:
    """View gateway logs."""
    import platform as plat

    if plat.system() == "Darwin":
        click.echo("Check ~/Library/Logs/com.diapason.gateway.log")
    else:
        subprocess.run(
            ["journalctl", "--user", "-u", "diapason-gateway", "-f"],
            check=False,
        )