~ubuntu-branches/ubuntu/trusty/uwsgi/trusty

« back to all changes in this revision

Viewing changes to welcome.py

  • Committer: Package Import Robot
  • Author(s): Janos Guljas
  • Date: 2012-02-13 03:43:28 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20120213034328-d02hz8m5pon6kaxf
Tags: 1.0.3+dfsg-1
* New upstream version.
* Adjust rack plugin LD_RUN_PATH patch.
* Adjust patch for uWSGI Control Center jQuery links in templates.
* Remove '-fno-strict-aliasing' CFLAG patch as it is implemented upstream.
* Remove fix indentation of uwsgidecorators_py patch as implemented upstream.
* Adjust init scripts to use top-bottom options order, as --inherit option
  is not working as in earlier versions. 
* Update debian/copyright file.
* Add LSB Description field to debian/uwsgi.init.d.
* Set Architecture to "all" for binary package uwsgi-extra because
  it contains no architecture dependent files.
* Change uwsgi description. (Closes: #640698)
* New binary packages:
  - uwsgi-plugin-carbon
  - uwsgi-plugin-graylog2
  - uwsgi-plugin-logsocket
  - uwsgi-plugin-probeconnect
  - uwsgi-plugin-probepg
  - uwsgi-plugin-rrdtool
  - uwsgi-plugin-rsyslog
  - uwsgi-plugin-signal
  - uwsgi-plugin-symcall
  - uwsgi-plugin-syslog
* python-uwsgidecorators:
  - fix binary-install rule to call dh_python2
  - remove debian/source.lintian-overrides
* uwsgi-plugin-jvm-openjdk-6:
  - fix FTBFS on armel and powerpc (Closes: #656280)
* uwsgi-plugin-python:
  - document issue "ImportError: No module named site" when using
    virtualenv with Python 2.6 in README.Debian (Closes: #654333)
* Adjust debian/watch uversionmangle option.
* Repack upstram source to remove minimized jQuery and jQuery UI JavaScript
  libraries:
  - add get-orig-source rule to debian/rules
  - append +dfsg to upstream version
  - update debian/watch with dversionmangle option

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import uwsgi
2
 
 
 
2
import os
 
3
import gc
 
4
import sys
 
5
from uwsgidecorators import *
 
6
gc.set_debug(gc.DEBUG_SAVEALL)
 
7
 
 
8
print(os.environ)
 
9
print(sys.modules)
 
10
print(sys.argv)
 
11
 
 
12
try:
 
13
    if sys.argv[1] == 'debug':
 
14
        DEBUG = True
 
15
    else:
 
16
        raise
 
17
except:
 
18
    DEBUG = False
 
19
 
 
20
 
 
21
def after_request_hook():
 
22
    print "request finished"
 
23
 
 
24
uwsgi.after_req_hook = after_request_hook
 
25
 
 
26
def xsendfile(e, sr):
 
27
    sr('200 OK', [('Content-Type', 'image/png'), ('X-Sendfile', os.path.abspath('logo_uWSGI.png'))])
 
28
    return ''
3
29
 
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))
12
38
 
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])
17
43
 
18
44
routes = {}
 
45
routes['/xsendfile'] = xsendfile
19
46
routes['/logo'] = serve_logo
20
47
routes['/config'] = serve_config
21
48
routes['/options'] = serve_options
22
49
 
 
50
@postfork
 
51
def setprocname():
 
52
    if uwsgi.worker_id() > 0:
 
53
        uwsgi.setprocname("i am the worker %d" % uwsgi.worker_id())
 
54
 
23
55
def application(env, start_response):
24
56
 
 
57
    try:
 
58
        uwsgi.mule_msg(env['REQUEST_URI'], 1)
 
59
    except:
 
60
        pass
 
61
 
 
62
    req = uwsgi.workers()[uwsgi.worker_id()-1]['requests']
 
63
 
 
64
    uwsgi.setprocname("worker %d managed %d requests" % (uwsgi.worker_id(), req))
 
65
 
 
66
    try:
 
67
        gc.collect(2)
 
68
    except:
 
69
        pass
 
70
    if DEBUG:
 
71
        print(env['wsgi.input'].fileno())
 
72
 
25
73
    if routes.has_key(env['PATH_INFO']):
26
74
        return routes[env['PATH_INFO']](env, start_response)
27
75
 
28
76
    start_response('200 OK', [('Content-Type', 'text/html')])
29
77
 
 
78
    if DEBUG:
 
79
        print(env['wsgi.input'].fileno())
 
80
 
 
81
    try:
 
82
        gc.collect(2)
 
83
    except:
 
84
        pass
 
85
 
 
86
    if DEBUG:
 
87
        print(len(gc.get_objects()))
 
88
 
 
89
    workers = ''
 
90
    for w in uwsgi.workers():
 
91
        apps = '<table border="1"><tr><th>id</th><th>mountpoint</th><th>requests</th></tr>'
 
92
        for app in w['apps']:
 
93
            apps += '<tr><td>%d</td><td>%s</td><td>%d</td></tr>' % (app['id'], app['mountpoint'], app['requests']) 
 
94
        apps += '</table>'
 
95
        workers += """
 
96
<tr>
 
97
<td>%d</td><td>%d</td><td>%s</td><td>%d</td><td>%d</td><td>%d</td><td>%s</td>
 
98
</tr>
 
99
        """ % (w['id'], w['pid'], w['status'], w['running_time']/1000, w['avg_rt']/1000, w['tx'], apps)
 
100
 
30
101
    return """
31
 
<img src="/logo"/> version %s<br/>
 
102
<img src="/logo"/> version %s running on %s<br/>
32
103
<hr size="1"/>
33
104
 
34
105
Configuration<br/>
39
110
Dynamic options<br/>
40
111
<iframe src="/options"></iframe><br/>
41
112
 
42
 
    """ % (uwsgi.version)
 
113
<br/>
 
114
Workers and applications<br/>
 
115
<table border="1">
 
116
<tr>
 
117
<th>wid</th><th>pid</th><th>status</th><th>running time</th><th>average</th><th>tx</th><th>apps</th>
 
118
</tr>
 
119
%s
 
120
</table>
 
121
 
 
122
    """ % (uwsgi.version, uwsgi.hostname, workers)
43
123
 
44
124
 
45
125