Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 960b4fb

Browse files
authored
complement-synapse-workers: factor out separate entry point script (#12467)
... with a bit more verbosity.
1 parent a743f7d commit 960b4fb

File tree

3 files changed

+58
-33
lines changed

3 files changed

+58
-33
lines changed

changelog.d/12467.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
complement-synapse-workers: factor out separate entry point script.

docker/complement/SynapseWorkers.Dockerfile

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ RUN curl -OL "https://github.com/caddyserver/caddy/releases/download/v2.3.0/cadd
1313
tar xzf caddy_2.3.0_linux_amd64.tar.gz && rm caddy_2.3.0_linux_amd64.tar.gz && mv caddy /root
1414

1515
# Install postgresql
16-
RUN apt-get update
17-
RUN apt-get install -y postgresql
16+
RUN apt-get update && \
17+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y postgresql-13
1818

1919
# Configure a user and create a database for Synapse
2020
RUN pg_ctlcluster 13 main start && su postgres -c "echo \
@@ -34,40 +34,14 @@ WORKDIR /data
3434
# Copy the caddy config
3535
COPY conf-workers/caddy.complement.json /root/caddy.json
3636

37+
# Copy the entrypoint
38+
COPY conf-workers/start-complement-synapse-workers.sh /
39+
3740
# Expose caddy's listener ports
3841
EXPOSE 8008 8448
3942

40-
ENTRYPOINT \
41-
# Replace the server name in the caddy config
42-
sed -i "s/{{ server_name }}/${SERVER_NAME}/g" /root/caddy.json && \
43-
# Start postgres
44-
pg_ctlcluster 13 main start 2>&1 && \
45-
# Start caddy
46-
/root/caddy start --config /root/caddy.json 2>&1 && \
47-
# Set the server name of the homeserver
48-
SYNAPSE_SERVER_NAME=${SERVER_NAME} \
49-
# No need to report stats here
50-
SYNAPSE_REPORT_STATS=no \
51-
# Set postgres authentication details which will be placed in the homeserver config file
52-
POSTGRES_PASSWORD=somesecret POSTGRES_USER=postgres POSTGRES_HOST=localhost \
53-
# Specify the workers to test with
54-
SYNAPSE_WORKER_TYPES="\
55-
event_persister, \
56-
event_persister, \
57-
background_worker, \
58-
frontend_proxy, \
59-
event_creator, \
60-
user_dir, \
61-
media_repository, \
62-
federation_inbound, \
63-
federation_reader, \
64-
federation_sender, \
65-
synchrotron, \
66-
appservice, \
67-
pusher" \
68-
# Run the script that writes the necessary config files and starts supervisord, which in turn
69-
# starts everything else
70-
/configure_workers_and_start.py
43+
ENTRYPOINT /start-complement-synapse-workers.sh
7144

45+
# Update the healthcheck to have a shorter check interval
7246
HEALTHCHECK --start-period=5s --interval=1s --timeout=1s \
7347
CMD /bin/sh /healthcheck.sh
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
#
3+
# Default ENTRYPOINT for the docker image used for testing synapse with workers under complement
4+
5+
set -e
6+
7+
function log {
8+
d=$(date +"%Y-%m-%d %H:%M:%S,%3N")
9+
echo "$d $@"
10+
}
11+
12+
# Replace the server name in the caddy config
13+
sed -i "s/{{ server_name }}/${SERVER_NAME}/g" /root/caddy.json
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+
# Set the server name of the homeserver
22+
export SYNAPSE_SERVER_NAME=${SERVER_NAME}
23+
24+
# No need to report stats here
25+
export SYNAPSE_REPORT_STATS=no
26+
27+
# Set postgres authentication details which will be placed in the homeserver config file
28+
export POSTGRES_PASSWORD=somesecret
29+
export POSTGRES_USER=postgres
30+
export POSTGRES_HOST=localhost
31+
32+
# Specify the workers to test with
33+
export SYNAPSE_WORKER_TYPES="\
34+
event_persister, \
35+
event_persister, \
36+
background_worker, \
37+
frontend_proxy, \
38+
event_creator, \
39+
user_dir, \
40+
media_repository, \
41+
federation_inbound, \
42+
federation_reader, \
43+
federation_sender, \
44+
synchrotron, \
45+
appservice, \
46+
pusher"
47+
48+
# Run the script that writes the necessary config files and starts supervisord, which in turn
49+
# starts everything else
50+
exec /configure_workers_and_start.py

0 commit comments

Comments
 (0)