##// END OF EJS Templates
gunicorn: small improvment of config.
marcink -
r1549:dac63b41 default
parent child Browse files
Show More
@@ -1,90 +1,90 b''
1 1 """
2 2 gunicorn config extension and hooks. Sets additional configuration that is
3 3 available post the .ini config.
4 4
5 5 - workers = ${cpu_number}
6 6 - threads = 1
7 7 - proc_name = ${gunicorn_proc_name}
8 8 - worker_class = sync
9 9 - worker_connections = 10
10 10 - max_requests = 1000
11 11 - max_requests_jitter = 30
12 12 - timeout = 21600
13 13
14 14 """
15 15
16 16 import multiprocessing
17 17 import sys
18 18 import threading
19 19 import traceback
20 20
21 21
22 22 # GLOBAL
23 23 errorlog = '-'
24 24 accesslog = '-'
25 25 loglevel = 'debug'
26 26
27 27 # SECURITY
28 28 limit_request_line = 4094
29 29 limit_request_fields = 100
30 30 limit_request_field_size = 8190
31 31
32 32 # SERVER MECHANICS
33 33 # None == system temp dir
34 34 worker_tmp_dir = None
35 35 tmp_upload_dir = None
36 36
37 37 # Custom log format
38 38 access_log_format = (
39 '%(t)s GNCRN %(p)-8s %(h)-15s rqt:%(L)s %(s)s %(b)s "%(m)s:%(U)s %(q)s" usr:%(u)s "%(f)s" "%(a)s"')
39 '%(t)s GNCRN %(p)-8s %(h)-15s rqt:%(L)s %(s)s %(b)-6s "%(m)s:%(U)s %(q)s" usr:%(u)s "%(f)s" "%(a)s"')
40 40
41 41 # self adjust workers based on CPU count
42 42 # workers = multiprocessing.cpu_count() * 2 + 1
43 43
44 44
45 45 def post_fork(server, worker):
46 46 server.log.info("[<%-10s>] WORKER spawned", worker.pid)
47 47
48 48
49 49 def pre_fork(server, worker):
50 50 pass
51 51
52 52
53 53 def pre_exec(server):
54 54 server.log.info("Forked child, re-executing.")
55 55
56 56
57 57 def when_ready(server):
58 58 server.log.info("Server is ready. Spawning workers")
59 59
60 60
61 61 def worker_int(worker):
62 62 worker.log.info("[<%-10s>] worker received INT or QUIT signal", worker.pid)
63 63
64 64 # get traceback info, on worker crash
65 65 id2name = dict([(th.ident, th.name) for th in threading.enumerate()])
66 66 code = []
67 67 for thread_id, stack in sys._current_frames().items():
68 68 code.append(
69 69 "\n# Thread: %s(%d)" % (id2name.get(thread_id, ""), thread_id))
70 70 for fname, lineno, name, line in traceback.extract_stack(stack):
71 71 code.append('File: "%s", line %d, in %s' % (fname, lineno, name))
72 72 if line:
73 73 code.append(" %s" % (line.strip()))
74 74 worker.log.debug("\n".join(code))
75 75
76 76
77 77 def worker_abort(worker):
78 78 worker.log.info("[<%-10s>] worker received SIGABRT signal", worker.pid)
79 79
80 80
81 81 def pre_request(worker, req):
82 82 return
83 83 worker.log.debug("[<%-10s>] PRE WORKER: %s %s",
84 84 worker.pid, req.method, req.path)
85 85
86 86
87 87 def post_request(worker, req, environ, resp):
88 88 return
89 89 worker.log.debug("[<%-10s>] POST WORKER: %s %s resp: %s", worker.pid,
90 90 req.method, req.path, resp.status_code) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now