2022-07-19 12:37:20 +00:00
# Creating multiple generic workers with a bash script
2022-07-11 17:33:53 +00:00
Setting up multiple worker configuration files manually can be time-consuming.
You can alternatively create multiple worker configuration files with a simple `bash` script. For example:
```sh
#!/bin/bash
for i in {1..5}
do
2022-09-21 14:58:46 +00:00
cat < < EOF > generic_worker$i.yaml
2022-07-11 17:33:53 +00:00
worker_app: synapse.app.generic_worker
worker_name: generic_worker$i
# The replication listener on the main synapse process.
worker_replication_host: 127.0.0.1
worker_replication_http_port: 9093
worker_listeners:
- type: http
port: 808$i
2023-01-13 14:06:58 +00:00
x_forwarded: true
2022-07-11 17:33:53 +00:00
resources:
- names: [client, federation]
worker_log_config: /etc/matrix-synapse/generic-worker-log.yaml
2023-01-13 14:06:58 +00:00
#worker_pid_file: DATADIR/generic_worker$i.pid
2022-07-11 17:33:53 +00:00
EOF
done
```
This would create five generic workers with a unique `worker_name` field in each file and listening on ports 8081-8085.
2023-01-13 14:06:58 +00:00
Customise the script to your needs. Note that `worker_pid_file` is required if `worker_daemonize` is `true` . Uncomment and/or modify the line if needed.