atipugin / telegram-bot-ruby

Ruby wrapper for Telegram's Bot API
https://core.telegram.org/bots/api
Do What The F*ck You Want To Public License
1.35k stars 217 forks source link

TERM trap does not work anymore as in README #298

Closed eugene-nikolaev closed 8 months ago

eugene-nikolaev commented 10 months ago

Hi!

TERM trap does not work for me as in README:

Signal.trap('INT') do
  bot.stop
end

I'm not sure - no chance to dig deeper at the moment, but it seems Faraday sets it's own trap and handles TERM that wait so program waits for the connection timeout and then exits. "bot stop" trap isn't called.

Maybe it is possible to disable Faraday's handler somehow 🤷

% ruby -v                                                                                                                                                                                                                              
ruby 3.2.2 (2023-03-30 revision e51014f9c0) [arm64-darwin22]

% gem info faraday                                                                                                                                                                                                                     

*** LOCAL GEMS ***

faraday (2.7.11)
    Authors: @technoweenie, @iMacTia, @olleolleolle
    Homepage: https://lostisland.github.io/faraday
    License: MIT
    Installed at: /Users/eugene/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0

    HTTP/REST API client library.

% gem info telegram-bot-ruby                                                                                                                                                                                                           

*** LOCAL GEMS ***

telegram-bot-ruby (1.0.0)
    Author: Alexander Tipugin
    Homepage: https://github.com/atipugin/telegram-bot
    Installed at: /Users/eugene/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0

    Ruby wrapper for Telegram's Bot API
eugene-nikolaev commented 10 months ago

Ah it seems bot.stop is not released yet

atipugin commented 10 months ago

@eugene-nikolaev Hi! Yes, try using the master branch for now (until the next release)

eugene-nikolaev commented 10 months ago

trap("TERM") seems not be working for me in the master as well. The program just exits instantly without calling the handler.

I've checked trap("QUIT") and it calls it (though not closing the program for sure).

AlexWayfer commented 10 months ago

trap("TERM") seems not be working for me in the master as well. The program just exits instantly without calling the handler.

I've checked trap("QUIT") and it calls it (though not closing the program for sure).

You're writing about TERM signal, but quoting documentation about INT.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.