A
A
Alexander Dupliy2018-11-19 18:03:03
Bots
Alexander Dupliy, 2018-11-19 18:03:03

How to organize a bot fault tolerance (long running process)?

Hello. There is a telegram bot. You need to hang it somewhere online and organize fault tolerance. How to do it right? Please provide links to good tutorials. At the moment, the bot stack is: PHP + Redis.
In essence, a bot is a long-running process , either it makes requests to api.telegram.org itself, or it listens to new apps using the webhook feature. If this process fails, then the bot itself will understandably not process requests from the user. It is necessary to organize fault tolerance so that either this process raises itself (I used to use such a utility as supervisord for this) or so that the second process with the bot is automatically launched and it already processes requests. I don't know how it's done in the modern world. Best practices links would be very helpful.
Also interested in additional features, such as notifications in case of failure of one of the subsystems, for example Redis, and collection, processing and output of logs somewhere (Elasticsearch + Logstash?).
Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
rPman, 2018-11-21
@rPman

Is your bot a normal cli php process? what's the problem, run it with a simple command Will endlessly try to run php main.php with a pause between runs of 1 second. Of course, you can run it from any other application in another programming language, even the same php. Take care of writing logs and sending messages after each crash (or, for example, exceeding their number for a certain period, or with special error messages, etc.) so that you, as an administrator, know what is happening, otherwise the application will suddenly terminate immediately after launch, for example from -for a syntax error in the configuration file.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question