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.
 
 

68 lines
3.2 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. PartOf=matrix.target
  7. [Service]
  8. Type=simple
  9. Environment="HOME={{ matrix_systemd_unit_home_path }}"
  10. ExecStartPre=-{{ matrix_host_command_docker }} stop {{ matrix_synapse_worker_container_name }}
  11. ExecStartPre=-{{ matrix_host_command_docker }} rm {{ matrix_synapse_worker_container_name }}
  12. # Intentional delay, so that the homeserver can manage to start.
  13. ExecStartPre={{ matrix_host_command_sleep }} 5
  14. ExecStart={{ matrix_host_command_docker }} run --rm --name {{ matrix_synapse_worker_container_name }} \
  15. --log-driver=none \
  16. --user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
  17. -e UID={{ matrix_user_uid }} \
  18. -e GID={{ matrix_user_gid }} \
  19. --cap-drop=ALL \
  20. --read-only \
  21. --tmpfs=/tmp:rw,noexec,nosuid,size={{ matrix_synapse_tmp_directory_size_mb }}m \
  22. --network={{ matrix_docker_network }} \
  23. {% if matrix_synapse_worker_details.port != 0 %}
  24. --health-cmd 'curl -fSs http://localhost:{{ matrix_synapse_worker_details.port }}/health || exit 1' \
  25. {% else %}
  26. --no-healthcheck \
  27. {% endif %}
  28. {% if matrix_synapse_workers_enabled and matrix_synapse_workers_container_host_bind_address %}
  29. {% if matrix_synapse_worker_details.port != 0 %}
  30. -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 }} \
  31. {% endif %}
  32. {% if matrix_synapse_worker_details.metrics_port != 0 %}
  33. -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 }} \
  34. {% endif %}
  35. {% endif %}
  36. --mount type=bind,src={{ matrix_synapse_config_dir_path }},dst=/data,ro \
  37. --mount type=bind,src={{ matrix_synapse_storage_path }},dst=/matrix-media-store-parent,bind-propagation=slave \
  38. {% for volume in matrix_synapse_container_additional_volumes %}
  39. -v {{ volume.src }}:{{ volume.dst }}:{{ volume.options }} \
  40. {% endfor %}
  41. {% for arg in matrix_synapse_container_extra_arguments %}
  42. {{ arg }} \
  43. {% endfor %}
  44. {{ matrix_synapse_docker_image }} \
  45. run -m synapse.app.{{ matrix_synapse_worker_details.type }} -c /data/homeserver.yaml -c /data/{{ matrix_synapse_worker_config_file_name }}
  46. ExecStop=-{{ matrix_host_command_docker }} stop {{ matrix_synapse_worker_container_name }}
  47. ExecStop=-{{ matrix_host_command_docker }} rm {{ matrix_synapse_worker_container_name }}
  48. ExecReload={{ matrix_host_command_docker }} exec {{ matrix_synapse_worker_container_name }} /bin/sh -c 'kill -HUP 1'
  49. Restart=always
  50. RestartSec=30
  51. SyslogIdentifier={{ matrix_synapse_worker_container_name }}
  52. # Intentionally not making this WantedBy=matrix-synapse.service,
  53. # as matrix.synapse.service already has `Wants=` lines.
  54. # Also, WantedBy will trigger the creation of some `matrix-synapse.service.wants/` directory,
  55. # which we'd have to clean, etc. Better not.
  56. [Install]
  57. WantedBy=matrix.target