fix shutdown
This commit is contained in:
parent
5f8bcd2ffa
commit
b416edfcf9
@ -21,6 +21,7 @@ class Folder
|
||||
|
||||
def close()
|
||||
self.update()
|
||||
puts "folder closed"
|
||||
end
|
||||
|
||||
def num_subs()
|
||||
|
11
main.rb
11
main.rb
@ -20,9 +20,8 @@ logger.info("loaded config")
|
||||
bot = Discordrb::Commands::CommandBot.new token: config_obj["bot_token"], prefix: "!folder"
|
||||
folder = Folder.new
|
||||
|
||||
def shutdown
|
||||
log.info("shutting down")
|
||||
if bot.connected
|
||||
def shut_down(bot,folder)
|
||||
if bot.connected?
|
||||
bot.stop
|
||||
end
|
||||
folder.close
|
||||
@ -102,14 +101,14 @@ bot.message(private: true) do |event|
|
||||
end
|
||||
|
||||
#set up signals
|
||||
Signal.trap("INT") {
|
||||
shut_down
|
||||
Signal.trap("INT") {
|
||||
shut_down(bot,folder)
|
||||
exit
|
||||
}
|
||||
|
||||
# Trap `Kill `
|
||||
Signal.trap("TERM") {
|
||||
shut_down
|
||||
shut_down(bot,folder)
|
||||
exit
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user