Created
April 13, 2011 15:31
-
-
Save guohai/917756 to your computer and use it in GitHub Desktop.
FastCGI+Nginx+Trac启动测试
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| #encoding: utf8 | |
| from flup.server.fcgi import WSGIServer | |
| def myapp(environ, start_response): | |
| start_response('200 OK', [('Content-Type', 'text/plain')]) | |
| return ['Hello World!\n你好,世界!'] | |
| if __name__ == '__main__': | |
| WSGIServer(myapp, bindAddress=('127.0.0.1',8080)).run() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| #encoding: utf8 | |
| import os | |
| sockaddr = ('127.0.0.1', 8080) | |
| os.environ['TRAC_ENV'] = '/path/to/projectenv' | |
| try: | |
| from trac.web.main import dispatch_request | |
| import trac.web._fcgi | |
| fcgiserv = trac.web._fcgi.WSGIServer(dispatch_request, | |
| bindAddress = sockaddr, umask = 7) | |
| fcgiserv.run() | |
| except SystemExit: | |
| raise | |
| except Exception, e: | |
| print 'Content-Type: text/plain\r\n\r\n', | |
| print 'Oops...' | |
| print 'Trac detected an internal error:' | |
| print e | |
| import traceback | |
| import StringIO | |
| tb = StringIO.StringIO() | |
| traceback.print_exc(file=tb) | |
| print tb.getvalue() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment