Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

59 regels
2.9 KiB

  1. #jinja2: lstrip_blocks: "True"
  2. [Unit]
  3. Description=Synapse worker ({{ matrix_synapse_worker_container_name }})
  4. AssertPathExists={{ matrix_synapse_config_dir_path }}/{{ matrix_synapse_worker_config_file_name }}
  5. After=matrix-synapse.service
  6. [Service]
  7. Type=simple
  8. Environment="HOME={{ matrix_systemd_unit_home_path }}"
  9. ExecStartPre=-{{ matrix_host_command_docker }} kill {{ matrix_synapse_worker_container_name }}
  10. ExecStartPre=-{{ matrix_host_command_docker }} rm {{ matrix_synapse_worker_container_name }}
  11. # Intentional delay, so that the homeserver can manage to start.
  12. ExecStartPre={{ matrix_host_command_sleep }} 5
  13. ExecStart={{ matrix_host_command_docker }} run --rm --name {{ matrix_synapse_worker_container_name }} \
  14. --log-driver=none \
  15. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  16. --cap-drop=ALL \
  17. --entrypoint=python \
  18. --read-only \
  19. --tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \
  20. --network={{ matrix_docker_network }} \
  21. {% if matrix_synapse_workers_enabled and matrix_synapse_workers_container_host_bind_address %}
  22. {% if matrix_synapse_worker_details.port != 0 %}
  23. -p {{ '' if matrix_synapse_workers_container_host_bind_address == '*' else (matrix_synapse_workers_container_host_bind_address + ':') }}{{ matrix_synapse_worker_details.port }}:{{ matrix_synapse_worker_details.port }} \
  24. {% endif %}
  25. {% if matrix_synapse_worker_details.metrics_port != 0 %}
  26. -p {{ '' if matrix_synapse_workers_container_host_bind_address == '*' else (matrix_synapse_workers_container_host_bind_address + ':') }}{{ matrix_synapse_worker_details.metrics_port }}:{{ matrix_synapse_worker_details.metrics_port }} \
  27. {% endif %}
  28. {% endif %}
  29. --mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/data,ro \
  30. --mount type=bind,src={{ matrix_synapse_storage_path }},dst=/matrix-media-store-parent,bind-propagation=slave \
  31. {% for volume in matrix_synapse_container_additional_volumes %}
  32. -v {{ volume.src }}:{{ volume.dst }}:{{ volume.options }} \
  33. {% endfor %}
  34. {% for arg in matrix_synapse_container_extra_arguments %}
  35. {{ arg }} \
  36. {% endfor %}
  37. {{ matrix_synapse_docker_image }} \
  38. -m synapse.app.{{ matrix_synapse_worker_details.type }} -c /data/homeserver.yaml -c /data/{{ matrix_synapse_worker_config_file_name }}
  39. ExecStop=-{{ matrix_host_command_docker }} kill {{ matrix_synapse_worker_container_name }}
  40. ExecStop=-{{ matrix_host_command_docker }} rm {{ matrix_synapse_worker_container_name }}
  41. ExecReload={{ matrix_host_command_docker }} exec {{ matrix_synapse_worker_container_name }} /bin/sh -c 'kill -HUP 1'
  42. Restart=always
  43. RestartSec=30
  44. SyslogIdentifier={{ matrix_synapse_worker_container_name }}
  45. # Intentionally not making this WantedBy=matrix-synapse.service,
  46. # as matrix.synapse.service already has `Wants=` lines.
  47. # Also, WantedBy will trigger the creation of some `matrix-synapse.service.wants/` directory,
  48. # which we'd have to clean, etc. Better not.
  49. [Install]
  50. WantedBy=multi-user.target