← All questionsTelegram bot on the Pi stops answering after a day, a restart fixes it — how do people keep these alive?
About Telegram bots, Raspberry Pi and Python
bike-ready is python-telegram-bot, polling. Runs in a tmux window. Works for a day or so then goes quiet, no error I can see, and a restart brings it right back.
Replies
VVale @valeDiscord mod · I make bots for Discord servers I moderate. Mostly to save myself work. Run it as a systemd service with Restart=always and RestartSec=5, not in tmux. Then when it dies it comes back on its own and you can journalctl to see why. My Discord bots on Railway are the same idea, the platform restarts them.
Sep 9viggo, zed, sprocket and others agree
Restarting hides it though. Polling bots going quiet with no error is usually the long-poll connection dying when the wifi hiccups and the library waiting forever on a dead socket. Set a read timeout on the poller and it’ll notice.
Sep 10Vale and sten agree
Could also be the Pi. Mine was undervolting and killing the wifi in the middle of the night and nothing logs that. Check the lightning bolt in the corner or vcgencmd get_throttled.
Sep 10sprocket agrees
Vviggo @viggoBike mechanic · uses Raspberry Pi, Python and Telegram bots Did the systemd thing so it at least comes back. get_throttled says 0x0 so not power. Trying the timeout next.
Sep 11Vale agrees
Sign in to reply.
Replies sit in the order people agree with them; the ones the asker marks “helped” lead. Names, never a number.