In a telegram bot written in c#, I use the following code to catch the bot shutting down(SIGTERM call):
using Mono.Unix;
using Mono.Unix.Native;
public class UnixExitSignal
{
private event EventHandler OnExecute;
private readonly UnixSignal[] signals = new UnixSignal[]{
new UnixSignal(Signum.SIGTERM),
};
public UnixExitSignal(EventHandler OnExecute)
{
this.OnExecute = OnExecute;
}
public void Wait()
{
_ = Task.Factory.StartNew(() =>
{
_ = UnixSignal.WaitAny(signals, -1);
OnExecute(null, EventArgs.Empty);
});
}
}
After a certain amount of time I meet this error:
Conflict: terminated by other getUpdates request; make sure that only one bot instance is running
How can I correctly complete the task so as not to meet the above error in the future?