From 98446561cf3c7126dd93b34c9be361fa4aa8da36 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Sat, 29 May 2021 18:47:29 +0200 Subject: fix: restart logger thread after fork Logging was broken when daemonizing, due to the logger thread being dead after the fork. This can be solved by restarting the thread, if necessary when setting the log file (which we conveniently do right after the fork). --- bin/rbot | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/rbot b/bin/rbot index 82ee9c9a..8c65f42c 100755 --- a/bin/rbot +++ b/bin/rbot @@ -111,14 +111,14 @@ if ($opts["help"]) exit 0 end -if(bot = Irc::Bot.new(ARGV.shift, :argv => orig_opts)) - # setup logger based on command line arguments - loglevel = $opts['loglevel'] ? $opts['loglevel'].to_i : nil - loglevel = $opts['debug'] ? 0 : loglevel - if loglevel - Irc::Bot::LoggerManager.instance.set_level(loglevel) - end +# setup logger based on command line arguments +loglevel = $opts['loglevel'] ? $opts['loglevel'].to_i : nil +loglevel = $opts['debug'] ? 0 : loglevel +if loglevel + Irc::Bot::LoggerManager.instance.set_level(loglevel) +end +if(bot = Irc::Bot.new(ARGV.shift, :argv => orig_opts)) # just run the bot bot.mainloop end -- cgit v1.2.3