Error message improvement.
authorEric S. Raymond <esr@thyrsus.com>
Fri, 5 Oct 2012 15:20:36 +0000 (11:20 -0400)
committerEric S. Raymond <esr@thyrsus.com>
Fri, 5 Oct 2012 15:20:36 +0000 (11:20 -0400)
irkerd

diff --git a/irkerd b/irkerd
index 436365cb658319086f8ca58ef2915890573f4e10..698aa36ea8078e9bef5982fe08366bf8fa7d3b29 100755 (executable)
--- a/irkerd
+++ b/irkerd
@@ -58,7 +58,7 @@ except ImportError:
     CONNECTION_MAX = 200
     green_threads = False
 
-import sys, getopt, urlparse, time, random
+import sys, getopt, urlparse, time, random, socket
 import threading, Queue, SocketServer
 import irc.client, logging
 try:
@@ -478,16 +478,19 @@ if __name__ == '__main__':
             sys.exit(0)
     irker = Irker(debuglevel=debuglvl)
     irker.debug(1, "irkerd version %s" % version)
-    tcpserver = SocketServer.TCPServer((HOST, PORT), IrkerTCPHandler)
-    udpserver = SocketServer.UDPServer((HOST, PORT), IrkerUDPHandler)
-    for server in [tcpserver, udpserver]:
-        server = threading.Thread(target=server.serve_forever)
-        server.setDaemon(True)
-        server.start()
     try:
-        while True:
-            time.sleep(10)
-    except KeyboardInterrupt:
-        raise SystemExit(1)
+        tcpserver = SocketServer.TCPServer((HOST, PORT), IrkerTCPHandler)
+        udpserver = SocketServer.UDPServer((HOST, PORT), IrkerUDPHandler)
+        for server in [tcpserver, udpserver]:
+            server = threading.Thread(target=server.serve_forever)
+            server.setDaemon(True)
+            server.start()
+        try:
+            while True:
+                time.sleep(10)
+        except KeyboardInterrupt:
+            raise SystemExit(1)
+    except socket.error, e:
+        sys.stderr.write("irkerd: server launch failed: %r\n" % e)
 
 # end