Re: RELEASED: scgi 1.11

Damjan <[email protected]>
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
> Well, it's reported to be much faster, and it's easier to control who
> can connect to your SCGI server, by seting unix file permissions.
> 
> The patch for scgi.py is simple, and lighttpd already supports it.

Oops, the wrong patch this is the real one (attached).

-- 
damjan | дамјан
This is my jabber ID -->         [email protected] 
 -- not my mail address, it's a Jabber ID --^ :)

_______________________________________________
Quixote-users mailing list
[email protected]
http://mail.mems-exchange.org/mailman/listinfo/quixote-users
scgi-unix-socket.patch (text/plain, 1.7 KB)
--- 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()
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.