summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-09 21:07:52 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-04-09 21:07:52 +0000
commit64affd3db4aaf1f65ea917f8851e6549311f3155 (patch)
tree08b643607ffe65279383c8bec132cfb6fc2356a8
parentad710dacfda0d260707f75e8998433602b5bc2c8 (diff)
fix restarting when directory had changed
-rw-r--r--lib/rbot/ircbot.rb14
1 files changed, 11 insertions, 3 deletions
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