Line | |
---|
1 | # -*- coding: utf-8 -*- |
---|
2 | |
---|
3 | __all__ = ["cache", "connectivity", "conversion", "tests", "views"] |
---|
4 | |
---|
5 | import logging |
---|
6 | |
---|
7 | logger = logging.getLogger('waitress') |
---|
8 | |
---|
9 | from resource import setrlimit, RLIMIT_NPROC |
---|
10 | |
---|
11 | from getpass import getuser |
---|
12 | |
---|
13 | unix_username = getuser() |
---|
14 | |
---|
15 | import pprint |
---|
16 | import resource |
---|
17 | |
---|
18 | try: |
---|
19 | from pyramid.config import Configurator |
---|
20 | from pyramid.settings import asbool |
---|
21 | |
---|
22 | def main(global_config, |
---|
23 | **settings): |
---|
24 | |
---|
25 | try: |
---|
26 | settings['max_n_threads'] = int(settings['max_n_threads']) |
---|
27 | settings['caching'] = asbool(settings['caching']) |
---|
28 | except (KeyError, TypeError, ValueError) as e: |
---|
29 | logger.error("Waitress configuration error. " + pprint.pformat(e)) |
---|
30 | else: |
---|
31 | |
---|
32 | setrlimit(RLIMIT_NPROC, (settings['max_n_threads'], settings['max_n_threads'])) |
---|
33 | |
---|
34 | config = Configurator(settings=settings) |
---|
35 | |
---|
36 | config.add_route("media_conv", |
---|
37 | "/media_conv") |
---|
38 | |
---|
39 | config.scan() |
---|
40 | |
---|
41 | return config.make_wsgi_app() |
---|
42 | except BlockingIOError as e: |
---|
43 | logger.critical("System resource limit for RLIMIT_NPROC (set to {0}) is being exceeded for current user '{1}'! {2}" |
---|
44 | .format(resource.getrlimit(RLIMIT_NPROC), unix_username, pprint.pformat(e))) |
---|
45 | raise |
---|
Note: See
TracBrowser
for help on using the repository browser.