-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathcore.j2
118 lines (112 loc) · 5.68 KB
/
core.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{{ ansible_managed | comment }}
{# NGINX Core template -- ngx_core_module #}
{% macro main(main) %}
{% if main['load_module'] is defined and main['load_module'] is not mapping %}
{% for module in main['load_module'] if main['load_module'] is not string %}
load_module {{ module }};
{% else %}
load_module {{ main['load_module'] }};
{% endfor %}
{% endif %}
{% if main['user'] is defined %}
user {{ main['user'] if main['user'] is string else main['user']['username'] if main['user']['username'] is defined }}{{ (' ' + main['user']['group'] | string) if main['user']['group'] is defined }};
{% endif %}
{% if main['worker_cpu_affinity'] is defined %}
worker_cpu_affinity{{ ' auto' if main['worker_cpu_affinity']['auto'] is defined and main['worker_cpu_affinity']['auto'] is boolean and main['worker_cpu_affinity']['auto'] | bool -}}
{{- ((' ' + main['worker_cpu_affinity']['cpumask'] | string) if main['worker_cpu_affinity']['cpumask'] is string else (' ' + main['worker_cpu_affinity']['cpumask'] | join(' '))) if main['worker_cpu_affinity']['cpumask'] is defined }};
{% endif %}
{% if main['worker_priority'] is defined and main['worker_priority'] is number %}
worker_priority {{ main['worker_priority'] }};
{% endif %}
{% if main['worker_processes'] is defined and (main['worker_processes'] is number or main['worker_processes'] == 'auto') %}
worker_processes {{ main['worker_processes'] }};
{% endif %}
{% if main['worker_rlimit_core'] is defined %}
worker_rlimit_core {{ main['worker_rlimit_core'] }};
{% endif %}
{% if main['worker_rlimit_nofile'] is defined and main['worker_rlimit_nofile'] is number %}
worker_rlimit_nofile {{ main['worker_rlimit_nofile'] }};
{% endif %}
{% if main['worker_shutdown_timeout'] is defined %}
worker_shutdown_timeout {{ main['worker_shutdown_timeout'] }};
{% endif %}
{% if main['error_log'] is defined %}
{% for log in main['error_log'] if (main['error_log'] is not mapping and main['error_log'] is not string) %}
error_log {{ log if log is string else log['file'] }}{{ (' ' + log['level'] | string) if log['level'] is defined }};
{% else %}
error_log {{ main['error_log'] if main['error_log'] is string else main['error_log']['file'] }}{{ (' ' + main['error_log']['level'] | string) if main['error_log']['level'] is defined }};
{% endfor %}
{% endif %}
{% if main['pid'] is defined %}
pid {{ main['pid'] }};
{% endif %}
{% if main['daemon'] is defined and main['daemon'] is boolean %}
daemon {{ main['daemon'] | ternary('on', 'off') }};
{% endif %}
{% if main['debug_points'] is defined and main['debug_points'] in ['abort', 'stop'] %}
debug_points {{ main['debug_points'] }};
{% endif %}
{% if main['env'] is defined %}
{% for env in main['env'] if (main['env'] is not mapping and main['env'] is not string) %}
env {{ env if env is string else env['variable'] }}{{ ('=' + env['value'] | string) if env['value'] is defined }};
{% else %}
env {{ main['env'] if main['env'] is string else main['env']['variable'] }}{{ ('=' + main['env']['value'] | string) if main['env']['value'] is defined }};
{% endfor %}
{% endif %}
{% if main['lock_file'] is defined %}
lock_file {{ main['lock_file'] }};
{% endif %}
{% if main['master_process'] is defined and main['master_process'] is boolean %}
master_process {{ main['master_process'] | ternary('on', 'off') }};
{% endif %}
{% if main['pcre_jit'] is defined and main['pcre_jit'] is boolean %}
pcre_jit {{ main['pcre_jit'] | ternary('on', 'off') }};
{% endif %}
{% if main['ssl_engine'] is defined %}
ssl_engine {{ main['ssl_engine'] }};
{% endif %}
{% if main['thread_pool'] is defined and main['thread_pool'] is not string %}
{% for thread in main['thread_pool'] if main['thread_pool'] is not mapping %}
thread_pool {{ thread['name'] }} {{ ('threads=' + thread['threads'] | string) if thread['threads'] is number }}{{ (' max_queue=' + thread['max_queue'] | string) if thread['max_queue'] is defined and thread['max_queue'] is number }};
{% else %}
thread_pool {{ main['thread_pool']['name'] }} {{ ('threads=' + main['thread_pool']['threads'] | string) if main['thread_pool']['threads'] is number }}{{ (' max_queue=' + main['thread_pool']['max_queue'] | string) if main['thread_pool']['max_queue'] is defined and main['thread_pool']['max_queue'] is number }};
{% endfor %}
{% endif %}
{% if main['timer_resolution'] is defined %}
timer_resolution {{ main['timer_resolution'] }};
{% endif %}
{% if main['working_directory'] is defined %}
working_directory {{ main['working_directory'] }};
{% endif %}
{% if main['quic'] is defined %}
{% from 'http/modules.j2' import quic with context %}
{{ quic(main['quic'], 'global') }}
{% endif %}
{% endmacro %}
{% macro events(events) %}
{% if events['accept_mutex'] is defined and events['accept_mutex'] is boolean %}
accept_mutex {{ events['accept_mutex'] | ternary('on', 'off') }};
{% endif %}
{% if events['accept_mutex_delay'] is defined %}
accept_mutex_delay {{ events['accept_mutex_delay'] }};
{% endif %}
{% if events['debug_connection'] is defined and events['debug_connection'] is not mapping %}
{% for connection in events['debug_connection'] if events['debug_connection'] is not string %}
debug_connection {{ connection }};
{% else %}
debug_connection {{ events['debug_connection'] }};
{% endfor %}
{% endif %}
{% if events['multi_accept'] is defined and events['multi_accept'] is boolean %}
multi_accept {{ events['multi_accept'] | ternary('on', 'off') }};
{% endif %}
{% if events['use'] is defined %}
use {{ events['use'] }};
{% endif %}
{% if events['worker_aio_requests'] is defined and events['worker_aio_requests'] is number %}
worker_aio_requests {{ events['worker_aio_requests'] }};
{% endif %}
{% if events['worker_connections'] is defined and events['worker_connections'] is number %}
worker_connections {{ events['worker_connections'] }};
{% endif %}
{% endmacro %}