This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree 9 files changed +44
-12
lines changed
9 files changed +44
-12
lines changed Original file line number Diff line number Diff line change
1
+ Use supervisord to supervise Postgres and Caddy in the Complement image to reduce restart time.
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ RUN rm /etc/nginx/sites-enabled/default
20
20
# Copy Synapse worker, nginx and supervisord configuration template files
21
21
COPY ./docker/conf-workers/* /conf/
22
22
23
+ # Copy a script to prefix log lines with the supervisor program name
24
+ COPY ./docker/prefix-log /usr/local/bin/
25
+
23
26
# Expose nginx listener port
24
27
EXPOSE 8080/tcp
25
28
Original file line number Diff line number Diff line change @@ -34,13 +34,16 @@ WORKDIR /data
34
34
# Copy the caddy config
35
35
COPY conf-workers/caddy.complement.json /root/caddy.json
36
36
37
+ COPY conf-workers/postgres.supervisord.conf /etc/supervisor/conf.d/postgres.conf
38
+ COPY conf-workers/caddy.supervisord.conf /etc/supervisor/conf.d/caddy.conf
39
+
37
40
# Copy the entrypoint
38
41
COPY conf-workers/start-complement-synapse-workers.sh /
39
42
40
43
# Expose caddy's listener ports
41
44
EXPOSE 8008 8448
42
45
43
- ENTRYPOINT /start-complement-synapse-workers.sh
46
+ ENTRYPOINT [ " /start-complement-synapse-workers.sh" ]
44
47
45
48
# Update the healthcheck to have a shorter check interval
46
49
HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \
Original file line number Diff line number Diff line change
1
+ [program:caddy]
2
+ command=/usr/local/bin/prefix-log /root/caddy run --config /root/caddy.json
3
+ autorestart=unexpected
4
+ stdout_logfile=/dev/stdout
5
+ stdout_logfile_maxbytes=0
6
+ stderr_logfile=/dev/stderr
7
+ stderr_logfile_maxbytes=0
Original file line number Diff line number Diff line change
1
+ [program:postgres]
2
+ command=/usr/local/bin/prefix-log /usr/bin/pg_ctlcluster 13 main start --foreground
3
+
4
+ # Lower priority number = starts first
5
+ priority=1
6
+
7
+ autorestart=unexpected
8
+ stdout_logfile=/dev/stdout
9
+ stdout_logfile_maxbytes=0
10
+ stderr_logfile=/dev/stderr
11
+ stderr_logfile_maxbytes=0
12
+
13
+ # Use 'Fast Shutdown' mode which aborts current transactions and closes connections quickly.
14
+ # (Default (TERM) is 'Smart Shutdown' which stops accepting new connections but
15
+ # lets existing connections close gracefully.)
16
+ stopsignal=INT
Original file line number Diff line number Diff line change @@ -12,12 +12,6 @@ function log {
12
12
# Replace the server name in the caddy config
13
13
sed -i " s/{{ server_name }}/${SERVER_NAME} /g" /root/caddy.json
14
14
15
- log " starting postgres"
16
- pg_ctlcluster 13 main start
17
-
18
- log " starting caddy"
19
- /root/caddy start --config /root/caddy.json
20
-
21
15
# Set the server name of the homeserver
22
16
export SYNAPSE_SERVER_NAME=${SERVER_NAME}
23
17
Original file line number Diff line number Diff line change @@ -2,11 +2,7 @@ version: 1
2
2
3
3
formatters:
4
4
precise:
5
- {% if worker_name %}
6
- format: '%(asctime)s - worker:{{ worker_name }} - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
7
- {% else %}
8
5
format: '%(asctime)s - %(name)s - %(lineno)d - %(levelname)s - %(request)s - %(message)s'
9
- {% endif %}
10
6
11
7
handlers:
12
8
{% if LOG_FILE_PATH %}
Original file line number Diff line number Diff line change 171
171
# Templates for sections that may be inserted multiple times in config files
172
172
SUPERVISORD_PROCESS_CONFIG_BLOCK = """
173
173
[program:synapse_{name}]
174
- command=/usr/local/bin/python -m {app} \
174
+ command=/usr/local/bin/prefix-log /usr/local/bin/ python -m {app} \
175
175
--config-path="{config_path}" \
176
176
--config-path=/conf/workers/shared.yaml \
177
177
--config-path=/conf/workers/{name}.yaml
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ #
3
+ # Prefixes all lines on stdout and stderr with the process name (as determined by
4
+ # the SUPERVISOR_PROCESS_NAME env var, which is automatically set by Supervisor).
5
+ #
6
+ # Usage:
7
+ # prefix-log command [args...]
8
+ #
9
+
10
+ exec 1> >( awk ' {print "' " ${SUPERVISOR_PROCESS_NAME} " ' | "$0}' >&1 )
11
+ exec 2> >( awk ' {print "' " ${SUPERVISOR_PROCESS_NAME} " ' | "$0}' >&2 )
12
+ exec " $@ "
You can’t perform that action at this time.
0 commit comments