Update redirector to run as uwsgi app
authorMagnus Hagander <magnus@hagander.net>
Thu, 31 Dec 2015 14:03:23 +0000 (15:03 +0100)
committerMagnus Hagander <magnus@hagander.net>
Thu, 31 Dec 2015 14:03:23 +0000 (15:03 +0100)
Since we use uwsgi for the django interfaces as of 1.8, doing the same
for the redirector just makes things easier.

redirector/.gitignore [new file with mode: 0644]
redirector/redir.ini.sample [new file with mode: 0644]
redirector/redirector.py

diff --git a/redirector/.gitignore b/redirector/.gitignore
new file mode 100644 (file)
index 0000000..8e8111e
--- /dev/null
@@ -0,0 +1 @@
+redir.ini
diff --git a/redirector/redir.ini.sample b/redirector/redir.ini.sample
new file mode 100644 (file)
index 0000000..97c943b
--- /dev/null
@@ -0,0 +1,2 @@
+[planet]
+db=dbname=planetpg
index 5d56d5b11ed9691e87748bfb337e28d69918e4a3..7d4a507ad7e415aee353b03b2bec03f2f7ba3321 100755 (executable)
@@ -11,7 +11,6 @@ Copyright (C) 2011 PostgreSQL Global Development Group
 
 import ConfigParser
 import psycopg2
-from flup.server.fcgi import WSGIServer
 
 # Simple map used to shorten id values to URLs
 _urlvalmap = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '-', '_']
@@ -25,7 +24,7 @@ def iddecode(idstr):
                idval += _urlvalmap.index(c)
        return idval
 
-def redirapp(environ, start_response):
+def application(environ, start_response):
        try:
                # Start by getting the id from the request
                id = iddecode(environ['PATH_INFO'].split('/')[-1])
@@ -71,8 +70,6 @@ def redirapp(environ, start_response):
                        ]
 
 
-if __name__ == '__main__':
-       c = ConfigParser.ConfigParser()
-       c.read('redir.ini')
-       connstr = c.get('planet', 'db')
-       WSGIServer(redirapp).run()
+c = ConfigParser.ConfigParser()
+c.read('redir.ini')
+connstr = c.get('planet', 'db')