mxssl / tg-captcha-bot

Telegram Сaptcha Bot
https://t.me/cloud_tg_captcha_bot
MIT License
264 stars 87 forks source link

Service crashes with /getUpdates:EOF #16

Closed helioloureiro closed 3 years ago

helioloureiro commented 3 years ago

Hi,

Just got this from the logs:

Feb 19 13:21:18 tg-captcha-bot[15469]: 2021/02/19 13:21:18 Post https://api.telegram.org/<redacted>:<redacted>/getUpdates: EOF
Feb 19 13:21:18 tg-captcha-bot[15469]: telebot
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.wrapError
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/util.go:46
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.(*Bot).Raw
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/api.go:32
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.(*Bot).getUpdates
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/api.go:219
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.(*LongPoller).Poll
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/poller.go:100
Feb 19 13:21:18 tg-captcha-bot[15469]: runtime.goexit
Feb 19 13:21:18 tg-captcha-bot[15469]:         /usr/lib/go-1.13/src/runtime/asm_amd64.s:1357
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.(*Bot).debug
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/util.go:14
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.(*LongPoller).Poll
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/poller.go:102
Feb 19 13:21:18 tg-captcha-bot[15469]: runtime.goexit
Feb 19 13:21:18 tg-captcha-bot[15469]:         /usr/lib/go-1.13/src/runtime/asm_amd64.s:1357
Feb 19 13:21:18 tg-captcha-bot[15469]: 2021/02/19 13:21:18 telebot: could not fetch new updates
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.init
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/telebot.go:36
Feb 19 13:21:18 tg-captcha-bot[15469]: runtime.doInit
Feb 19 13:21:18 tg-captcha-bot[15469]:         /usr/lib/go-1.13/src/runtime/proc.go:5222
Feb 19 13:21:18 tg-captcha-bot[15469]: runtime.doInit
Feb 19 13:21:18 tg-captcha-bot[15469]:         /usr/lib/go-1.13/src/runtime/proc.go:5217
Feb 19 13:21:18 tg-captcha-bot[15469]: runtime.main
Feb 19 13:21:18 tg-captcha-bot[15469]:         /usr/lib/go-1.13/src/runtime/proc.go:190
Feb 19 13:21:18 tg-captcha-bot[15469]: runtime.goexit
Feb 19 13:21:18 tg-captcha-bot[15469]:         /usr/lib/go-1.13/src/runtime/asm_amd64.s:1357
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.(*Bot).debug
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/util.go:14
Feb 19 13:21:18 tg-captcha-bot[15469]: gopkg.in/tucnak/telebot%2ev2.(*LongPoller).Poll
Feb 19 13:21:18 tg-captcha-bot[15469]:         /home/helio/go/pkg/mod/gopkg.in/tucnak/telebot.v2@v2.3.5/poller.go:103
Feb 19 13:21:18 tg-captcha-bot[15469]: runtime.goexit
Feb 19 13:21:18 tg-captcha-bot[15469]:         /usr/lib/go-1.13/src/runtime/asm_amd64.s:1357
Feb 19 14:18:00 tg-captcha-bot[15469]: 2021/02/19 14:18:00 Shutdown signal received, exiting...

Since it didn't really died at 13:21:18, I had to manually restart the service at 14:18:00. It is running on systemd.

mxssl commented 3 years ago

If there is a network problem and the app can't get updates from the Telegram API for timeout time (it's configured for 10 seconds by default), then the app stopped: https://github.com/mxssl/tg-captcha-bot/blob/master/main.go#L68

As a solution, you can add a restart option to your systemd config file:

[Unit]
Description=tg-captcha-bot
Wants=network-online.target
After=network-online.target

[Service]
Environment="TGTOKEN=your_token"
Environment="CONFIG_PATH=/etc/tg-captcha-bot"
Type=simple
ExecStart=/usr/local/bin/tg-captcha-bot

Restart=always
RestartSec=3s

[Install]
WantedBy=multi-user.target