Files
2026-07-12 10:17:17 -04:00

106 lines
3.2 KiB
Markdown

# Gateway Restart & Test Message Reference
## Checking Gateway Status
```
ps aux | grep 'hermes gateway run'
```
Note the PID and whether it's running as Ssl (stable).
## Checking for systemd Service
```
systemctl --user list-units --type=service --all | grep -i hermes
```
Empty response = gateway was started manually, not systemd-managed.
## Manual Restart Sequence (no systemd)
```
# 1. Find and kill old gateway
ps aux | grep 'hermes gateway run'
kill -9 <PID> # -9 if plain kill doesn't work
sleep 2
# 2. Verify it's dead
ps aux | grep 'hermes gateway run'
# 3. Start fresh
# In the Hermes CLI, use:
# terminal(background=true, notify_on_complete=true, command="hermes gateway run")
# Do NOT use nohup, disown, or trailing & in foreground terminal()
```
## Verifying Telegram Connection in Logs
Log file: `~/.hermes/logs/gateway.log`
### Lines confirming a successful connection:
```
Connecting to telegram...
[Telegram] Auto-discovered Telegram fallback IPs: 149.154.166.110
[Telegram] set_my_commands OK for scope BotCommandScopeDefault (30 cmds)
[Telegram] Connected to Telegram (polling mode)
✓ telegram connected
```
### Quick grep check:
```
grep -E "(telegram connected|Connecting to telegram|Connected to Telegram)" ~/.hermes/logs/gateway.log
```
## Sending a Test Message (CLI Workaround)
The `send_message` Hermes tool does NOT work from CLI sessions for Telegram — it returns "No messaging platforms connected". Use the Telegram Bot API directly via curl:
```
curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
-d "chat_id=${CHAT_ID}" \
-d "text=Hello from Hermes!"
```
### Expected response on success:
```json
{"ok":true,"result":{"message_id":677,"from":{"id":8971430276,"is_bot":true,...},"chat":{"id":1498679692,...},"date":1780001714,"text":"Hello from Hermes!"}}
```
If `"ok":true`, the message was delivered. You can also add `-d "parse_mode=HTML"` for rich text formatting.
## .env Configuration Snippets
### Default state (all commented out):
```
# TELEGRAM_BOT_TOKEN=*** TELEGRAM_ALLOWED_USERS=
# TELEGRAM_HOME_CHANNEL=
# TELEGRAM_HOME_CHANNEL_NAME=
```
### After configuration — split into separate lines:
```env
TELEGRAM_BOT_TOKEN=your_bot_token_here
TELEGRAM_ALLOWED_USERS=123456789
TELEGRAM_HOME_CHANNEL=123456789
TELEGRAM_HOME_CHANNEL_NAME=@yourusername
```
### sed commands to uncomment (one per line):
```
sed -i 's|^# TELEGRAM_ALLOWED_USERS=.*|TELEGRAM_ALLOWED_USERS=123456789|' ~/.hermes/.env
sed -i 's|^# TELEGRAM_HOME_CHANNEL=.*|TELEGRAM_HOME_CHANNEL=123456789|' ~/.hermes/.env
sed -i 's|^# TELEGRAM_HOME_CHANNEL_NAME=.*|TELEGRAM_HOME_CHANNEL_NAME=@username|' ~/.hermes/.env
```
**Caveat on TELEGRAM_BOT_TOKEN:** The default template has `TELEGRAM_BOT_TOKEN` and `TELEGRAM_ALLOWED_USERS` on the same commented line. The simple `sed` to uncomment probably won't work cleanly. Verify the exact line format with `grep -n 'TELEGRAM_BOT_TOKEN' ~/.hermes/.env` and replace the entire line if needed, or delete the old line and insert fresh ones.
## Token Visibility Note
In gateway logs and grep output, the bot token may appear partially masked (e.g., `TELEGRAM_BOT_TOKEN=***...***`). This is normal log sanitization — the full token is still loaded and used by the gateway process.