From: Magnus Hagander Date: Thu, 31 Dec 2015 14:03:23 +0000 (+0100) Subject: Update redirector to run as uwsgi app X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=4486acd34781d4048fc0b1cac164f13510070aac;p=hamn.git Update redirector to run as uwsgi app Since we use uwsgi for the django interfaces as of 1.8, doing the same for the redirector just makes things easier. --- diff --git a/redirector/.gitignore b/redirector/.gitignore new file mode 100644 index 0000000..8e8111e --- /dev/null +++ b/redirector/.gitignore @@ -0,0 +1 @@ +redir.ini diff --git a/redirector/redir.ini.sample b/redirector/redir.ini.sample new file mode 100644 index 0000000..97c943b --- /dev/null +++ b/redirector/redir.ini.sample @@ -0,0 +1,2 @@ +[planet] +db=dbname=planetpg diff --git a/redirector/redirector.py b/redirector/redirector.py index 5d56d5b..7d4a507 100755 --- a/redirector/redirector.py +++ b/redirector/redirector.py @@ -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')