39 lines
1.1 KiB
Bash
Executable File
39 lines
1.1 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
generate_upstream_block () {
|
|
name=$1
|
|
workers=$2
|
|
balancing_method=$3
|
|
|
|
if [ -n "$workers" ]; then
|
|
echo "upstream $name {"
|
|
|
|
for server in $workers; do
|
|
echo " server $server;"
|
|
done
|
|
|
|
if [ -n "$balancing_method" ]; then
|
|
echo "$balancing_method;"
|
|
fi
|
|
|
|
echo "}"
|
|
fi
|
|
}
|
|
|
|
# Inbound federation requests go to the same worker (based on IP).
|
|
generate_upstream_block inbound_federation_workers "$FEDERATION_WORKERS" ip_hash
|
|
|
|
# For /sync and /initialSync requests it will be more efficient if all requests
|
|
# from a particular user are routed to a single instance. Extracting a user ID
|
|
# from the access token or Authorization header is a pain, so we just group by
|
|
# IP address: a specific user will use one address per client, but should not
|
|
# have too many clients...
|
|
generate_upstream_block sync_workers "$SYNC_WORKERS" ip_hash
|
|
|
|
# Client, event seding and outbound federation are round-robin.
|
|
generate_upstream_block federation_workers "$FEDERATION_WORKERS"
|
|
generate_upstream_block client_workers "$CLIENT_WORKERS"
|
|
generate_upstream_block event_sending_workers "$EVENT_SENDING_WORKERS"
|