Implement synchrotron balancing in nginx, replaces need for matrix-synchrotron-balancer
This commit is contained in:
@@ -9,10 +9,6 @@ matrix_max_upload_size_mb: 100
|
||||
synapse_metrics: false
|
||||
synapse_presence: true
|
||||
|
||||
synchrotron_workers:
|
||||
balancer: generic_sync
|
||||
init: generic_init_sync
|
||||
|
||||
persister_workers:
|
||||
- event_persister
|
||||
- typing_persister
|
||||
|
||||
@@ -21,3 +21,10 @@
|
||||
enabled: true
|
||||
loop: "{{ synapse_worker_services }}"
|
||||
notify: Config matrix target
|
||||
|
||||
- name: Disable matrix-synchrotrons
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
name: matrix-synchrotron@{{ item }}.service
|
||||
enabled: false
|
||||
loop: "{{ synapse_synchrotrons }}"
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
---
|
||||
|
||||
- name: Ensure workdir exists for matrix-synchrotron-{{ item }}
|
||||
ansible.builtin.file:
|
||||
path: /opt/matrix-synchrotron/{{ item }}
|
||||
state: directory
|
||||
mode: 0755
|
||||
|
||||
- name: Ensure config in place for matrix-synchrotron-{{ item }}
|
||||
ansible.builtin.template:
|
||||
src: matrix-synchrotron-config.yaml.j2
|
||||
dest: /opt/matrix-synchrotron/{{ item }}/config.yaml.ansibled
|
||||
mode: 0644
|
||||
notify: Config synapse service
|
||||
register: config
|
||||
|
||||
- name: Copy config to final destination for matrix-synchrotron-{{ item }}
|
||||
ansible.builtin.copy:
|
||||
src: /opt/matrix-synchrotron/{{ item }}/config.yaml.ansibled
|
||||
dest: /opt/matrix-synchrotron/{{ item }}/config.yaml
|
||||
remote_src: true
|
||||
mode: 0644
|
||||
when: config.changed
|
||||
@@ -1,53 +1,13 @@
|
||||
---
|
||||
|
||||
- name: Install git and golang
|
||||
ansible.builtin.apt:
|
||||
name:
|
||||
- git
|
||||
- golang
|
||||
|
||||
- name: Create matrix-synchrotron user
|
||||
- name: Ensure matrix-synchrotron user not present
|
||||
ansible.builtin.user:
|
||||
name: matrix-synchrotron
|
||||
system: true
|
||||
home: /opt/matrix-synchrotron
|
||||
shell: /bin/false
|
||||
state: absent
|
||||
remove: true
|
||||
|
||||
- name: Install matrix-synchrotron
|
||||
become_user: matrix-synchrotron
|
||||
block:
|
||||
- name: Clone matrix-synchrotron git repo
|
||||
ansible.builtin.git:
|
||||
repo: https://github.com/Sorunome/matrix-synchrotron-balancer.git
|
||||
dest: /opt/matrix-synchrotron/src
|
||||
force: true
|
||||
register: install
|
||||
|
||||
- name: Build matrix-synchrotron
|
||||
ansible.builtin.command: go build
|
||||
args:
|
||||
chdir: /opt/matrix-synchrotron/src
|
||||
when: install.changed
|
||||
notify: Config synapse service
|
||||
|
||||
- name: Configure matrix-synchrotron(s)
|
||||
ansible.builtin.include_tasks: matrix-synchrotron.yml
|
||||
loop: "{{ synapse_synchrotrons }}"
|
||||
loop_control:
|
||||
extended: true
|
||||
|
||||
- name: Put systemd matrix-synchrotron unit in place
|
||||
ansible.builtin.template:
|
||||
src: systemd/matrix-synchrotron@.service.j2
|
||||
dest: /etc/systemd/system/matrix-synchrotron@.service
|
||||
mode: "644"
|
||||
register: systemd_unit
|
||||
|
||||
- name: Enable systemd unit matrix-synchrotron-{{ item }}
|
||||
ansible.builtin.systemd:
|
||||
daemon_reload: true
|
||||
name: matrix-synchrotron@{{ item }}.service
|
||||
enabled: true
|
||||
state: restarted
|
||||
when: systemd_unit.changed
|
||||
loop: "{{ synapse_synchrotrons }}"
|
||||
- name: Ensure matrix-synchrotron unit not present
|
||||
ansible.builtin.file:
|
||||
path: /etc/systemd/system/matrix-synchrotron@.service
|
||||
state: absent
|
||||
notify: Disable matrix-synchrotrons
|
||||
|
||||
@@ -47,6 +47,6 @@
|
||||
loop_control:
|
||||
loop_var: synapse_worker
|
||||
|
||||
- name: Configure synchrotron balancer
|
||||
- name: Ensure synchrotron balancer removed (legacy)
|
||||
ansible.builtin.include_tasks: matrix-synchrotrons.yml
|
||||
when: synapse_synchrotrons | length != 0
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
# {{ ansible_managed }}
|
||||
homeserver_url: http://localhost:8008 # homeserver URL for the whoami request
|
||||
listener: localhost:{{ 8183 + ansible_loop.index0 }} # host:port to listen to
|
||||
|
||||
synchrotrons:
|
||||
{% for port in synapse_workers[synchrotron_workers[item]] %}
|
||||
- address: 127.0.0.1:{{ port }}
|
||||
pid_file: /run/matrix-synapse/{{ synchrotron_workers[item] }}-{{ loop.index0 }}.pid
|
||||
{% endfor %}
|
||||
|
||||
balancer:
|
||||
interval: 2
|
||||
@@ -1,17 +0,0 @@
|
||||
# {{ ansible_managed }}
|
||||
|
||||
[Unit]
|
||||
Description=Matrix Synchrotron %i
|
||||
After=matrix-synapse.service
|
||||
PartOf=matrix-synapse.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=matrix-synchrotron
|
||||
WorkingDirectory=/opt/matrix-synchrotron/%i
|
||||
ExecStart=/opt/matrix-synchrotron/src/matrix-synchrotron-balancer
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=matrix-synapse.service
|
||||
Reference in New Issue
Block a user