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.
 
 

71 regels
4.0 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. Requires=matrix-synapse.service
  7. [Service]
  8. Type=simple
  9. Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
  10. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill {{ matrix_synapse_worker_container_name }} 2>/dev/null || true'
  11. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ matrix_synapse_worker_container_name }} 2>/dev/null || true'
  12. # Intentional delay, so that the homeserver can manage to start.
  13. ExecStartPre={{ matrix_host_command_sleep }} 5
  14. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
  15. --rm \
  16. --name={{ matrix_synapse_worker_container_name }} \
  17. --log-driver=none \
  18. --user={{ matrix_synapse_uid }}:{{ matrix_synapse_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_synapse_container_network }} \
  23. {% if matrix_synapse_worker_details.port != 0 and matrix_synapse_worker_details.webserving %}
  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_arguments %}
  42. {{ arg }} \
  43. {% endfor %}
  44. {{ matrix_synapse_docker_image_final }} \
  45. run -m synapse.app.{{ matrix_synapse_worker_details.app }} -c /data/homeserver.yaml -c /data/{{ matrix_synapse_worker_config_file_name }}
  46. {% for network in matrix_synapse_container_additional_networks %}
  47. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} {{ matrix_synapse_worker_container_name }}
  48. {% endfor %}
  49. ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach {{ matrix_synapse_worker_container_name }}
  50. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} kill {{ matrix_synapse_worker_container_name }} 2>/dev/null || true'
  51. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ matrix_synapse_worker_container_name }} 2>/dev/null || true'
  52. ExecReload={{ devture_systemd_docker_base_host_command_docker }} exec {{ matrix_synapse_worker_container_name }} /bin/sh -c 'kill -HUP 1'
  53. Restart=always
  54. RestartSec=30
  55. SyslogIdentifier={{ matrix_synapse_worker_container_name }}
  56. # Intentionally not making this WantedBy=matrix-synapse.service,
  57. # as matrix.synapse.service already has `Wants=` lines.
  58. # Also, WantedBy will trigger the creation of some `matrix-synapse.service.wants/` directory,
  59. # which we'd have to clean, etc. Better not.
  60. [Install]
  61. WantedBy=multi-user.target