-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Telegram gateway stops responding when terminal is closed on headless servers #1005
Description
Telegram gateway stops responding when terminal is closed on headless servers
Problem
On headless servers (Digital Ocean droplets, VPS, etc.), the Telegram/Discord/WhatsApp gateway stops responding to messages when the SSH terminal is closed, even though hermes gateway install was run and systemctl --user status hermes-gateway.service shows "active (running)".
Root Cause
The gateway is installed as a systemd user-level service (~/.config/systemd/user/hermes-gateway.service), but user-level services are automatically stopped when the user logs out unless linger is enabled via:
sudo loginctl enable-linger <username>Without this, the user's systemd manager (sd-pam) terminates on logout, killing all user services including the gateway.
Current Workaround
Users must manually enable linger after installation:
# Enable linger for the user
sudo loginctl enable-linger hermesagent
# Restart the gateway
systemctl --user restart hermes-gateway.serviceExpected Behavior
The documentation or installation should either:
- Auto-enable linger during
hermes gateway installif running with sudo privileges - Clear error message explaining that linger must be enabled for headless operation
- Document this requirement prominently in the setup guide
- Provide a systemd system service option (user-level vs system-level) for headless deployments
Impact
- Headless servers: Telegram/Discord/WhatsApp integrations break on SSH logout
- Production deployments: Service appears running but doesn't respond to messages
- User confusion:
systemctl --user statusshows "active (running)" but messages aren't received - User frustration: Users think the installation failed when it's actually a configuration requirement
Environment
- OS: Linux (headless VPS/Digital Ocean droplet)
- Hermes Agent: Latest version (installable via pip)
- Gateway: Installed via
hermes gateway install - Services: User-level systemd services (
~/.config/systemd/user/)
Suggested Fixes
Option A: Auto-detect and enable linger during install
# During `hermes gateway install`:
if [ "$(id -u)" = "0" ]; then
echo "Enabling linger for headless operation..."
loginctl enable-linger "$USER"
fiOption B: Add system-level service option
# Allow users to install as a system service instead of user service
hermes gateway install --system # Install as system service (persists across logins)Option C: Clear warning message in documentation
⚠️ On headless servers (VPS, cloud instances), you must run this after installation:sudo loginctl enable-linger $USERWithout this, the gateway will stop when you disconnect SSH.
Testing
To verify the issue exists:
- Install Hermes Agent
- Run
hermes gateway install - Start Telegram in
hermes gateway - Close SSH terminal
- Check if Telegram still responds (it won't without linger)
Related Issues
- This is a common systemd limitation for user services on headless systems
- Similar issues exist with other tools that use user-level services (e.g.,
dockerservices, custom daemons)