Gateway
The Moxxy gateway is the background daemon that powers all agent operations.
What is the Gateway?
The gateway is a persistent background process that:
- Manages Agents - Loads, initializes, and runs all configured agents
- Serves the API - Provides the REST API for web, TUI, and external integrations
- Connects Channels - Maintains connections to Telegram, Discord, Slack, WhatsApp
- Executes Schedules - Runs cron-based autonomous tasks
- Handles Webhooks - Processes incoming webhook requests
Lifecycle
┌─────────┐ ┌─────────┐ ┌─────────┐
│ start │ ──▶ │ running │ ──▶ │ stop │
└─────────┘ └─────────┘ └─────────┘
│
▼
┌──────────┐
│ restart │
└──────────┘Commands
Start
moxxy gateway startInitializes and starts the gateway daemon:
- Creates run directory (
~/.moxxy/run/) - Discovers all agents in
~/.moxxy/agents/ - Boots each agent (loads persona, memory, skills)
- Starts the API server (default: port 17890)
- Connects configured channels
- Begins schedule processing
- Writes PID file
Stop
moxxy gateway stopGracefully shuts down the daemon:
- Signals shutdown to all components
- Waits for in-flight requests to complete
- Saves agent state
- Disconnects channels
- Removes PID file
Restart
moxxy gateway restartEquivalent to stop followed by start. Useful for:
- Reloading configuration
- Applying persona changes
- Refreshing channel connections
Status
moxxy gateway statusDisplays current state:
● Gateway Status: Running
│
├─ PID: 12345
├─ Uptime: 2h 34m 12s
├─ API: http://127.0.0.1:17890
├─ Agents: 3 active
│
└─ Channels:
├─ Telegram: @my_bot (connected)
└─ Discord: MyServer (connected)Architecture
┌──────────────────────┐
│ Gateway Daemon │
└──────────────────────┘
│
┌─────────────────────┼─────────────────────┐
│ │ │
▼ ▼ ▼
┌───────────────┐ ┌───────────────────┐ ┌──────────────┐
│ API Server │ │ Channel Managers │ │ Scheduler │
│ (Axum/REST) │ │ TG/DC/SLACK/WA │ │ (Cron) │
└───────────────┘ └───────────────────┘ └──────────────┘
│ │ │
└─────────────────────┼─────────────────────┘
│
▼
┌──────────────────┐
│ Agent Pool │
│ ┌──┐ ┌──┐ ┌──┐ │
│ │A1│ │A2│ │A3│ │
│ └──┘ └──┘ └──┘ │
└──────────────────┘Process Management
PID File
The gateway writes its process ID to:
~/.moxxy/run/moxxy.pidThis is used to:
- Check if the gateway is running
- Send signals to the process
- Prevent duplicate instances
Logs
Gateway logs are written to:
~/.moxxy/logs/gateway.logView live logs:
moxxy logsAuto-Restart (Optional)
For production deployments, use a process manager:
launchd (macOS):
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.moxxy.gateway</string>
<key>ProgramArguments</key>
<array>
<string>/usr/local/bin/moxxy</string>
<string>gateway</string>
<string>start</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>systemd (Linux):
[Unit]
Description=Moxxy Gateway
After=network.target
[Service]
Type=simple
User=youruser
ExecStart=/usr/local/bin/moxxy gateway start
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.targetConfiguration
Ports
Default ports can be customized in the vault:
# Set custom API port
moxxy run --agent default --prompt "Store 18900 in vault as gateway_port"
# Set custom web UI port
moxxy run --agent default --prompt "Store 8080 in vault as web_ui_port"Host Binding
By default, the gateway binds to 127.0.0.1. To expose externally:
moxxy run --agent default --prompt "Store 0.0.0.0 in vault as gateway_host"WARNING
Binding to 0.0.0.0 exposes your API to the network. Ensure proper authentication and firewall rules.
Troubleshooting
Gateway Won't Start
Check for existing process:
bashcat ~/.moxxy/run/moxxy.pid ps aux | grep moxxyRemove stale PID file:
bashrm ~/.moxxy/run/moxxy.pidCheck logs:
bashcat ~/.moxxy/logs/gateway.log
Port Already in Use
# Find what's using the port
lsof -i :17890
# Kill the process or change the portAgents Not Loading
Run diagnostics:
moxxy doctorCheck agent directories:
ls -la ~/.moxxy/agents/