Skip to content

Instantly share code, notes, and snippets.

@guohai
Created April 13, 2011 15:31
Show Gist options
  • Select an option

  • Save guohai/917756 to your computer and use it in GitHub Desktop.

Select an option

Save guohai/917756 to your computer and use it in GitHub Desktop.
FastCGI+Nginx+Trac启动测试
#!/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()
#!/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
print 'Trac detected an internal error:'
print
print e
print
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