Skip to content

feat(gateway): add daemon mode and gateway lifecycle commands #42

@vaayne

Description

@vaayne

Summary

It would be very useful if anna gateway supported running as a background daemon directly, without requiring external tools like tmux, nohup, or manually managed process supervisors.

I’d like to propose:

  • anna gateway -d
  • anna gateway --daemon

And also a small lifecycle command group:

  • anna gateway start
  • anna gateway stop
  • anna gateway restart
  • anna gateway status

Motivation

Right now, running anna gateway persistently is a bit awkward.

Typical needs are:

  • start gateway in the background
  • check whether it is running
  • restart it after config changes
  • stop it cleanly

At the moment this usually requires extra shell scripting or tools like:

  • tmux
  • nohup
  • systemd
  • launchd

That works, but for a CLI like anna, built-in process management would make the UX much smoother.

Proposed UX

Option 1: daemon flag

anna gateway --daemon
anna gateway -d

Expected behavior:

  • starts gateway in background
  • writes pid file
  • optionally writes logs to a default location
  • prints useful metadata such as PID / log path
  • exits immediately after successful launch

Example output:

anna gateway started in background
PID: 12345
Log: ~/.anna/logs/gateway.log

Option 2: lifecycle subcommands

anna gateway start
anna gateway stop
anna gateway restart
anna gateway status

Expected behavior:

  • start: launch gateway if not running
  • stop: terminate existing gateway process gracefully
  • restart: stop then start
  • status: show whether gateway is running, PID, uptime, log path, and maybe configured channels

Possible examples:

anna gateway start --daemon
anna gateway status
anna gateway restart
anna gateway stop

Why this matters

This would make anna feel much more complete as a local assistant runtime.

Common workflows become much easier:

  • keep Telegram / other gateways online after login shell exits
  • recover from config changes quickly
  • avoid ad hoc tmux sessions
  • simplify scripting and onboarding

Implementation notes

A few things that may help:

  • pid file management
  • lock / single-instance protection
  • graceful shutdown handling
  • log file location convention
  • clear error message when a gateway instance is already running
  • status should ideally detect stale pid files

Nice-to-have

Potential future additions:

  • anna gateway logs
  • anna gateway start --log-file <path>
  • anna gateway stop --force
  • anna gateway status --json

Current workaround

Right now I’m using tmux to keep anna gateway alive, but this feels like something anna could handle natively.

Thanks — this would significantly improve day-to-day usability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions