5
from uwsgidecorators import *
6
gc.set_debug(gc.DEBUG_SAVEALL)
13
if sys.argv[1] == 'debug':
21
def after_request_hook():
22
print "request finished"
24
uwsgi.after_req_hook = after_request_hook
27
sr('200 OK', [('Content-Type', 'image/png'), ('X-Sendfile', os.path.abspath('logo_uWSGI.png'))])
4
30
def serve_logo(e, sr):
5
31
sr('200 OK', [('Content-Type', 'image/png')])
8
34
def serve_options(e, sr):
9
35
sr('200 OK', [('Content-Type', 'text/html')])
10
36
for opt in xrange(0,256):
11
yield "%d = %d<br/>" % (opt, uwsgi.get_option(opt))
37
yield "<b>%d</b> = %d<br/>" % (opt, uwsgi.get_option(opt))
13
39
def serve_config(e, sr):
14
40
sr('200 OK', [('Content-Type', 'text/html')])
15
41
for opt in uwsgi.opt.keys():
16
yield "%s = %s<br/>" % (opt, uwsgi.opt[opt])
42
yield "<b>%s</b> = %s<br/>" % (opt, uwsgi.opt[opt])
45
routes['/xsendfile'] = xsendfile
19
46
routes['/logo'] = serve_logo
20
47
routes['/config'] = serve_config
21
48
routes['/options'] = serve_options
52
if uwsgi.worker_id() > 0:
53
uwsgi.setprocname("i am the worker %d" % uwsgi.worker_id())
23
55
def application(env, start_response):
58
uwsgi.mule_msg(env['REQUEST_URI'], 1)
62
req = uwsgi.workers()[uwsgi.worker_id()-1]['requests']
64
uwsgi.setprocname("worker %d managed %d requests" % (uwsgi.worker_id(), req))
71
print(env['wsgi.input'].fileno())
25
73
if routes.has_key(env['PATH_INFO']):
26
74
return routes[env['PATH_INFO']](env, start_response)
28
76
start_response('200 OK', [('Content-Type', 'text/html')])
79
print(env['wsgi.input'].fileno())
87
print(len(gc.get_objects()))
90
for w in uwsgi.workers():
91
apps = '<table border="1"><tr><th>id</th><th>mountpoint</th><th>requests</th></tr>'
93
apps += '<tr><td>%d</td><td>%s</td><td>%d</td></tr>' % (app['id'], app['mountpoint'], app['requests'])
97
<td>%d</td><td>%d</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%s</td>
99
""" % (w['id'], w['pid'], w['status'], w['running_time']/1000, w['avg_rt']/1000, w['tx'], apps)
31
<img src="/logo"/> version %s<br/>
102
<img src="/logo"/> version %s running on %s<br/>
34
105
Configuration<br/>