--- scgi_server.py~ 2006-08-15 20:06:18.000000000 +0200 +++ scgi_server.py 2006-08-15 20:50:30.000000000 +0200 @@ -95,10 +95,11 @@ DEFAULT_PORT = 4000 def __init__(self, handler_class=SCGIHandler, host="", port=DEFAULT_PORT, - max_children=5): + unix_socket="", max_children=5): self.handler_class = handler_class self.host = host self.port = port + self.unix_socket = unix_socket self.max_children = max_children self.children = {} # { pid : fd } self.spawn_child() @@ -244,9 +245,13 @@ timeout = 2 def get_listening_socket(self): - s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) - s.bind((self.host, self.port)) + if self.unix_socket: + s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) + s.bind(self.unix_socket) + else: + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + s.bind((self.host, self.port)) return s def serve_on_socket(self, s): @@ -270,10 +275,17 @@ def main(): if len(sys.argv) == 2: - port = int(sys.argv[1]) + try: + port = int(sys.argv[1]) + except ValueError: + port = None + unix_socket = sys.argv[1] else: port = SCGIServer.DEFAULT_PORT - SCGIServer(port=port).serve() + if port: + SCGIServer(port=port).serve() + else: + SCGIServer(unix_socket=unix_socket).serve() if __name__ == "__main__": main()