From 14778157c6c969644f8839383cd0643543eea69b Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 14 Dec 2008 12:06:01 +0000 Subject: [PATCH] Better error handling and feedback. git-svn-id: svn+ssh://svn.luon.net/svn/ildus/trunk@17 65a33f86-aa00-0410-91be-cd1bf5efb309 --- bin/ildusd | 19 ++++++++++++------- lib/ildus/server.rb | 2 -- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/bin/ildusd b/bin/ildusd index 70aa14d..13fdb48 100644 --- a/bin/ildusd +++ b/bin/ildusd @@ -48,7 +48,7 @@ def print_version end # Argument parsing. -cfg_file = nil +cfg_file = "ildusd.conf" opts = GetoptLong.new( [ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ], [ '--help', '-h', GetoptLong::NO_ARGUMENT ], @@ -68,7 +68,10 @@ rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument end # Main. -puts < Ildus comes with ABSOLUTELY NO WARRANTY; This is free software, and you are welcome to redistribute it under certain conditions; for details see @@ -76,10 +79,12 @@ the COPYING file. START -server = Ildus::Server.new(cfg_file) + ['INT', 'TERM', 'QUIT'].each do |sig| + Signal.trap(sig) { server.shutdown } + end -['INT', 'TERM', 'QUIT'].each do |sig| - Signal.trap(sig) { server.shutdown } + server.start +rescue StandardError => e + puts "#{Program}: #{e}" + exit 2 end - -server.start diff --git a/lib/ildus/server.rb b/lib/ildus/server.rb index f5d894d..f754e97 100644 --- a/lib/ildus/server.rb +++ b/lib/ildus/server.rb @@ -60,8 +60,6 @@ module Ildus # Parses the configuration file _filename_ and stores the parsed # contents. def parse_config(filename) - raise ArgumentError unless FileTest.exists? filename - File.open(filename, "r") do |io| # FIXME: merge the YAML with a default config @config = YAML.load(io)