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
|
end
|
||||||
|
|
||||||
# Argument parsing.
|
# Argument parsing.
|
||||||
cfg_file = nil
|
cfg_file = "ildusd.conf"
|
||||||
opts = GetoptLong.new(
|
opts = GetoptLong.new(
|
||||||
[ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ],
|
[ '--config', '-c', GetoptLong::REQUIRED_ARGUMENT ],
|
||||||
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
[ '--help', '-h', GetoptLong::NO_ARGUMENT ],
|
||||||
|
@ -68,7 +68,10 @@ rescue GetoptLong::InvalidOption, GetoptLong::MissingArgument
|
||||||
end
|
end
|
||||||
|
|
||||||
# Main.
|
# Main.
|
||||||
puts <<START
|
|
||||||
|
begin
|
||||||
|
server = Ildus::Server.new(cfg_file)
|
||||||
|
puts <<-START
|
||||||
#{Program} #{Version} Copyright (C) 2005 Paul van Tilburg <paul@luon.net>
|
#{Program} #{Version} Copyright (C) 2005 Paul van Tilburg <paul@luon.net>
|
||||||
Ildus comes with ABSOLUTELY NO WARRANTY; This is free software, and you
|
Ildus comes with ABSOLUTELY NO WARRANTY; This is free software, and you
|
||||||
are welcome to redistribute it under certain conditions; for details see
|
are welcome to redistribute it under certain conditions; for details see
|
||||||
|
@ -76,10 +79,12 @@ the COPYING file.
|
||||||
|
|
||||||
START
|
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|
|
server.start
|
||||||
Signal.trap(sig) { server.shutdown }
|
rescue StandardError => e
|
||||||
|
puts "#{Program}: #{e}"
|
||||||
|
exit 2
|
||||||
end
|
end
|
||||||
|
|
||||||
server.start
|
|
||||||
|
|
|
@ -60,8 +60,6 @@ module Ildus
|
||||||
# Parses the configuration file _filename_ and stores the parsed
|
# Parses the configuration file _filename_ and stores the parsed
|
||||||
# contents.
|
# contents.
|
||||||
def parse_config(filename)
|
def parse_config(filename)
|
||||||
raise ArgumentError unless FileTest.exists? filename
|
|
||||||
|
|
||||||
File.open(filename, "r") do |io|
|
File.open(filename, "r") do |io|
|
||||||
# FIXME: merge the YAML with a default config
|
# FIXME: merge the YAML with a default config
|
||||||
@config = YAML.load(io)
|
@config = YAML.load(io)
|
||||||
|
|
Reference in New Issue