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