|
176 | 176 | } |
177 | 177 |
|
178 | 178 | # Templates for sections that may be inserted multiple times in config files |
179 | | -SUPERVISORD_PROCESS_CONFIG_BLOCK = """ |
180 | | -[program:synapse_{name}] |
181 | | -command=/usr/local/bin/prefix-log /usr/local/bin/python -m {app} \ |
182 | | - --config-path="{config_path}" \ |
183 | | - --config-path=/conf/workers/shared.yaml \ |
184 | | - --config-path=/conf/workers/{name}.yaml |
185 | | -autorestart=unexpected |
186 | | -priority=500 |
187 | | -exitcodes=0 |
188 | | -stdout_logfile=/dev/stdout |
189 | | -stdout_logfile_maxbytes=0 |
190 | | -stderr_logfile=/dev/stderr |
191 | | -stderr_logfile_maxbytes=0 |
192 | | -""" |
193 | | - |
194 | 179 | NGINX_LOCATION_CONFIG_BLOCK = """ |
195 | 180 | location ~* {endpoint} {{ |
196 | 181 | proxy_pass {upstream}; |
@@ -353,13 +338,10 @@ def generate_worker_files( |
353 | 338 | # This config file will be passed to all workers, included Synapse's main process. |
354 | 339 | shared_config: Dict[str, Any] = {"listeners": listeners} |
355 | 340 |
|
356 | | - # The supervisord config. The contents of which will be inserted into the |
357 | | - # base supervisord jinja2 template. |
358 | | - # |
359 | | - # Supervisord will be in charge of running everything, from redis to nginx to Synapse |
360 | | - # and all of its worker processes. Load the config template, which defines a few |
361 | | - # services that are necessary to run. |
362 | | - supervisord_config = "" |
| 341 | + # List of dicts that describe workers. |
| 342 | + # We pass this to the Supervisor template later to generate the appropriate |
| 343 | + # program blocks. |
| 344 | + worker_descriptors: List[Dict[str, Any]] = [] |
363 | 345 |
|
364 | 346 | # Upstreams for load-balancing purposes. This dict takes the form of a worker type to the |
365 | 347 | # ports of each worker. For example: |
@@ -437,7 +419,7 @@ def generate_worker_files( |
437 | 419 | ) |
438 | 420 |
|
439 | 421 | # Enable the worker in supervisord |
440 | | - supervisord_config += SUPERVISORD_PROCESS_CONFIG_BLOCK.format_map(worker_config) |
| 422 | + worker_descriptors.append(worker_config) |
441 | 423 |
|
442 | 424 | # Add nginx location blocks for this worker's endpoints (if any are defined) |
443 | 425 | for pattern in worker_config["endpoint_patterns"]: |
@@ -535,10 +517,16 @@ def generate_worker_files( |
535 | 517 | "/conf/supervisord.conf.j2", |
536 | 518 | "/etc/supervisor/supervisord.conf", |
537 | 519 | main_config_path=config_path, |
538 | | - worker_config=supervisord_config, |
539 | 520 | enable_redis=workers_in_use, |
540 | 521 | ) |
541 | 522 |
|
| 523 | + convert( |
| 524 | + "/conf/synapse.supervisord.conf.j2", |
| 525 | + "/etc/supervisor/conf.d/synapse.conf", |
| 526 | + workers=worker_descriptors, |
| 527 | + main_config_path=config_path, |
| 528 | + ) |
| 529 | + |
542 | 530 | # healthcheck config |
543 | 531 | convert( |
544 | 532 | "/conf/healthcheck.sh.j2", |
|
0 commit comments