From a7b1061f7546d9e3be894aa52a90c9a2f0fbae3c Mon Sep 17 00:00:00 2001 From: Dmitry Kim Date: Sat, 21 Apr 2007 17:58:25 +0000 Subject: + pidfile support + command line option for pid file name --- bin/rbot | 2 ++ lib/rbot/ircbot.rb | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/bin/rbot b/bin/rbot index 95076eb3..0a8fb7e9 100755 --- a/bin/rbot +++ b/bin/rbot @@ -68,6 +68,7 @@ opts = GetoptLong.new( ["--help", "-h", GetoptLong::NO_ARGUMENT], ["--loglevel", "-l", GetoptLong::REQUIRED_ARGUMENT], ["--trace", "-t", GetoptLong::REQUIRED_ARGUMENT], + ["--pidfile", "-p", GetoptLong::REQUIRED_ARGUMENT], ["--version", "-v", GetoptLong::NO_ARGUMENT] ) @@ -117,6 +118,7 @@ if ($opts["help"]) puts " -v, --version version information" puts " -d, --debug enable debug messages" puts " -b, --background background (daemonize) the bot" + puts " -p, --pidfile write the bot pid to this file" puts "config directory defaults to ~/.rbot" exit 0 end diff --git a/lib/rbot/ircbot.rb b/lib/rbot/ircbot.rb index b1ffb51f..f4c1f5bc 100644 --- a/lib/rbot/ircbot.rb +++ b/lib/rbot/ircbot.rb @@ -429,6 +429,10 @@ class Bot log_session_start + File.open($opts['pidfile'] || "#{@botclass}/rbot.pid", 'w') do |pf| + pf << "#{$$}\n" + end + @registry = BotRegistry.new self @timer = Timer::Timer.new(1.0) # only need per-second granularity -- cgit v1.2.3