1 | # (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org) |
---|
2 | # Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php |
---|
3 | from paste.deploy.converters import aslist, asbool |
---|
4 | from paste.script.serve import ensure_port_cleanup |
---|
5 | import warnings |
---|
6 | |
---|
7 | def warn(name, stacklevel=3): |
---|
8 | # Deprecated 2007-12-17 |
---|
9 | warnings.warn( |
---|
10 | 'The egg:PasteScript#flup_%s entry point is deprecated; please use egg:Flup#%s instead' |
---|
11 | % (name, name), |
---|
12 | DeprecationWarning, stacklevel=stacklevel) |
---|
13 | |
---|
14 | def run_ajp_thread(wsgi_app, global_conf, |
---|
15 | scriptName='', host='localhost', port='8009', |
---|
16 | allowedServers='127.0.0.1'): |
---|
17 | import flup.server.ajp |
---|
18 | warn('ajp_thread') |
---|
19 | addr = (host, int(port)) |
---|
20 | ensure_port_cleanup([addr]) |
---|
21 | s = flup.server.ajp.WSGIServer( |
---|
22 | wsgi_app, |
---|
23 | scriptName=scriptName, |
---|
24 | bindAddress=addr, |
---|
25 | allowedServers=aslist(allowedServers), |
---|
26 | ) |
---|
27 | s.run() |
---|
28 | |
---|
29 | def run_ajp_fork(wsgi_app, global_conf, |
---|
30 | scriptName='', host='localhost', port='8009', |
---|
31 | allowedServers='127.0.0.1'): |
---|
32 | import flup.server.ajp_fork |
---|
33 | warn('ajp_fork') |
---|
34 | addr = (host, int(port)) |
---|
35 | ensure_port_cleanup([addr]) |
---|
36 | s = flup.server.ajp_fork.WSGIServer( |
---|
37 | wsgi_app, |
---|
38 | scriptName=scriptName, |
---|
39 | bindAddress=addr, |
---|
40 | allowedServers=aslist(allowedServers), |
---|
41 | ) |
---|
42 | s.run() |
---|
43 | |
---|
44 | def run_fcgi_thread(wsgi_app, global_conf, |
---|
45 | host=None, port=None, |
---|
46 | socket=None, umask=None, |
---|
47 | multiplexed=False): |
---|
48 | import flup.server.fcgi |
---|
49 | warn('fcgi_thread') |
---|
50 | if socket: |
---|
51 | assert host is None and port is None |
---|
52 | sock = socket |
---|
53 | elif host: |
---|
54 | assert host is not None and port is not None |
---|
55 | sock = (host, int(port)) |
---|
56 | ensure_port_cleanup([sock]) |
---|
57 | else: |
---|
58 | sock = None |
---|
59 | if umask is not None: |
---|
60 | umask = int(umask) |
---|
61 | s = flup.server.fcgi.WSGIServer( |
---|
62 | wsgi_app, |
---|
63 | bindAddress=sock, umask=umask, |
---|
64 | multiplexed=asbool(multiplexed)) |
---|
65 | s.run() |
---|
66 | |
---|
67 | def run_fcgi_fork(wsgi_app, global_conf, |
---|
68 | host=None, port=None, |
---|
69 | socket=None, umask=None, |
---|
70 | multiplexed=False): |
---|
71 | import flup.server.fcgi_fork |
---|
72 | warn('fcgi_fork') |
---|
73 | if socket: |
---|
74 | assert host is None and port is None |
---|
75 | sock = socket |
---|
76 | elif host: |
---|
77 | assert host is not None and port is not None |
---|
78 | sock = (host, int(port)) |
---|
79 | ensure_port_cleanup([sock]) |
---|
80 | else: |
---|
81 | sock = None |
---|
82 | if umask is not None: |
---|
83 | umask = int(umask) |
---|
84 | s = flup.server.fcgi_fork.WSGIServer( |
---|
85 | wsgi_app, |
---|
86 | bindAddress=sock, umask=umask, |
---|
87 | multiplexed=asbool(multiplexed)) |
---|
88 | s.run() |
---|
89 | |
---|
90 | def run_scgi_thread(wsgi_app, global_conf, |
---|
91 | scriptName='', host='localhost', port='4000', |
---|
92 | allowedServers='127.0.0.1'): |
---|
93 | import flup.server.scgi |
---|
94 | warn('scgi_thread') |
---|
95 | addr = (host, int(port)) |
---|
96 | ensure_port_cleanup([addr]) |
---|
97 | s = flup.server.scgi.WSGIServer( |
---|
98 | wsgi_app, |
---|
99 | scriptName=scriptName, |
---|
100 | bindAddress=addr, |
---|
101 | allowedServers=aslist(allowedServers), |
---|
102 | ) |
---|
103 | s.run() |
---|
104 | |
---|
105 | def run_scgi_fork(wsgi_app, global_conf, |
---|
106 | scriptName='', host='localhost', port='4000', |
---|
107 | allowedServers='127.0.0.1'): |
---|
108 | import flup.server.scgi_fork |
---|
109 | warn('scgi_fork') |
---|
110 | addr = (host, int(port)) |
---|
111 | ensure_port_cleanup([addr]) |
---|
112 | s = flup.server.scgi_fork.WSGIServer( |
---|
113 | wsgi_app, |
---|
114 | scriptName=scriptName, |
---|
115 | bindAddress=addr, |
---|
116 | allowedServers=aslist(allowedServers), |
---|
117 | ) |
---|
118 | s.run() |
---|
119 | |
---|