["--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]
)
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
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