如何通过C#正确处理sigterm Signs Signs Signable?
在用C#编写的电报机器人中,我使用以下代码来捕获机器人关闭(sigterm呼叫):
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);
});
}
}
一定时间后,我遇到此错误:
冲突:其他getupdates请求终止;确保只有一个bot实例正在运行
我该如何正确完成任务,以便将来不遇到上述错误?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论