Score:0

How do we do autorestart for a freezing python daemon?

km flag

I have a Python daemon running on my Ubuntu 20.04 server. The daemon performs as a telegram bot which sends requests to the telegram server every the other second in a loop.

My daemon configuration telebot.service is as bellow:

[Unit]
Description=my telegram bot

[Service]
WorkingDirectory=/etc/telebot/dev
Environment=PYTHONPATH=/etc/telebot/dev
ExecStart=/etc/telebot/dev/venv/bin/telebot.py
TimeoutStartSec=0
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=telebot
Restart=on-failure

[Install]
WantedBy=multi-user.target

Whenever an exception is thrown inside my python code the daemon will restart automatically and this is a very good option. I also can read the logs and see why the exception happened and debug if applicable.

Sometimes however my daemon freezes. And I have to perform a restart manually to bring it back to execution. I do it with systemctl restart telebot.

Here I have two questions. Firstly in case of such freezes how one can investigate the issue? because there is no exception happened in the logs. How do I find out what is causing this?

Secondly, Does systemd provide and option to auto restart a freezing daemon? If not, are there any complementary tools which can do this?

PouJa avatar
km flag
This question really matters to me.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.