Better error handling and feedback.
git-svn-id: svn+ssh://svn.luon.net/svn/ildus/trunk@17 65a33f86-aa00-0410-91be-cd1bf5efb309
This commit is contained in:
parent
83a868f5f0
commit
14778157c6
19
bin/ildusd
19
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 <<START
|
||||
|
||||
begin
|
||||
server = Ildus::Server.new(cfg_file)
|
||||
puts <<-START
|
||||
#{Program} #{Version} Copyright (C) 2005 Paul van Tilburg <paul@luon.net>
|
||||
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
|
||||
|
|
|
@ -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)
|
||||
|
|
Reference in New Issue