windkh / node-red-contrib-telegrambot

Telegram bot nodes for node-red.
Other
266 stars 119 forks source link

Control node 'restart' vs full deploy ? #391

Open bonjour81 opened 1 month ago

bonjour81 commented 1 month ago

Hello,

Not really an issue, but a need for clarification (I was not sure where to post this).

1/ I have well noticed that 'full deploy' is recommended and I had trouble already when I did not (bot does not answer anymore to my commands, sometimes only after a few hours).

But I though that if I don't touch any telegram node, a more simple deploy may be good enough. Does this make sense or is it recommended to full deploy whatever I did in my flows, even if modifications does not touch any telegram node ?

2/ What is the purpose of control node 'restart' command ?
Does it cleanly re-init telegram node same as full deploy ? if so, a simple inject node to restart telegrambot at each deploy would do the job. what do you think ?

windkh commented 1 month ago

@bonjour81 the difference between partial and full deploy is that in full deploy the configuration nodes are completely recreated while in partial deploy the nodes only disconnect and reconnect to the configuration node. This was always a problem for the following reason: the configuration node contains logic for polling the messages from telegram server. The loop is inside a library underneath. It does not really support proper restarting. The only thing I can do is recreate an instance of the bot and start from scratch in full deploy. (which is the safest)

The control node was implemented due to these problems. You can detect of the polling loop runs or if it stalled using this node. Restart should stop and destroy the underlying instance and then it should create a new one. A restart of the control node can not recreate the config node from scratch (that can only be done by node red) but it does similar things with the telegram polling loop: it just kills it and recreates it.

--> you can try to restart your bot every few hours with the control node if you discover problems. However the bots I run here are completely stable and for that reason it would be helpful to find out what is wrong with your setup (maybe instable internet connection ...?)

bonjour81 commented 1 month ago

Hi ! Thank you for your feedback, Well, let me explain:

Considering I often forget, and that stall happen some hours after my work in flows, I was thinking that this restart function may do the job for me :)

What's the best way to detect is telegrambot is stalled ? Maybe this "msg.payload.isOnline" from control node ?

windkh commented 1 month ago

@bonjour81 I will adapt the control node so that an output is triggered as soon as the bot is offline

bonjour81 commented 1 month ago

That would be cool!