From 64affd3db4aaf1f65ea917f8851e6549311f3155 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Mon, 9 Apr 2007 21:07:52 +0000 Subject: fix restarting when directory had changed --- lib/rbot/ircbot.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'lib/rbot') diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index 619150fb..cb119378 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -289,6 +289,7 @@ class Bot :desc => "When truncating overlong messages (see send.overlong) or when sending too many lines per message (see send.max_lines) replace the end of the last line with this text") @argv = params[:argv] + @run_dir = params[:run_dir] || Dir.pwd unless FileTest.directory? Config::coredir error "core directory '#{Config::coredir}' not found, did you setup.rb?" @@ -1047,9 +1048,16 @@ class Bot msg = message ? message : "restarting, back in #{@config['server.reconnect_wait']}..." shutdown(msg) sleep @config['server.reconnect_wait'] - # now we re-exec - # Note, this fails on Windows - exec($0, *@argv) + begin + # now we re-exec + # Note, this fails on Windows + debug "going to exec #{$0} #{@argv.inspect} from #{@run_dir}" + Dir.chdir(@run_dir) + exec($0, *@argv) + rescue Exception => e + $interrupted += 1 + raise e + end end # call the save method for all of the botmodules -- cgit v1.2.3