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.
 
 

84 lines
5.9 KiB

  1. {#
  2. SPDX-FileCopyrightText: 2022 MDAD project contributors
  3. SPDX-FileCopyrightText: 2024 Slavi Pantaleev
  4. SPDX-FileCopyrightText: 2024 wjbeckett
  5. SPDX-FileCopyrightText: 2026 Suguru Hirahara
  6. SPDX-License-Identifier: AGPL-3.0-or-later
  7. #}
  8. [Unit]
  9. Description=LiveKit Server
  10. {% for service in livekit_server_systemd_required_services_list %}
  11. After={{ service }}
  12. Requires={{ service }}
  13. {% endfor %}
  14. {% for service in livekit_server_systemd_wanted_services_list %}
  15. Wants={{ service }}
  16. {% endfor %}
  17. [Service]
  18. Type=simple
  19. Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
  20. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} {{ livekit_server_identifier }} 2>/dev/null || true'
  21. ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ livekit_server_identifier }} 2>/dev/null || true'
  22. {% if livekit_server_host_sysctl_minimum_net_core_rmem_max %}
  23. ExecStartPre={{ devture_systemd_docker_base_host_command_sh }} -c 'current_rmem=$(sysctl -n net.core.rmem_max); if [ "$current_rmem" -lt {{ livekit_server_host_sysctl_minimum_net_core_rmem_max }} ]; then sysctl -w net.core.rmem_max={{ livekit_server_host_sysctl_minimum_net_core_rmem_max }}; fi'
  24. {% endif %}
  25. {% if livekit_server_host_sysctl_minimum_net_core_wmem_max %}
  26. ExecStartPre={{ devture_systemd_docker_base_host_command_sh }} -c 'current_wmem=$(sysctl -n net.core.wmem_max); if [ "$current_wmem" -lt {{ livekit_server_host_sysctl_minimum_net_core_wmem_max }} ]; then sysctl -w net.core.wmem_max={{ livekit_server_host_sysctl_minimum_net_core_wmem_max }}; fi'
  27. {% endif %}
  28. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
  29. --rm \
  30. --name={{ livekit_server_identifier }} \
  31. --log-driver=none \
  32. --user={{ livekit_server_uid }}:{{ livekit_server_gid }} \
  33. --cap-drop=ALL \
  34. --network={{ livekit_server_container_network }} \
  35. {% if livekit_server_container_rtc_listen_interface is not in [none, 'none'] %}
  36. -p {{ livekit_server_container_rtc_listen_interface }}{{ ':' if livekit_server_container_rtc_listen_interface else '' }}{{ livekit_server_config_rtc_tcp_port }}:{{ livekit_server_config_rtc_tcp_port }} \
  37. {% endif %}
  38. {% if livekit_server_container_rtc_listen_interface is not in [none, 'none'] and livekit_server_config_rtc_port_range_start and livekit_server_config_rtc_port_range_end %}
  39. -p {{ livekit_server_container_rtc_listen_interface }}{{ ':' if livekit_server_container_rtc_listen_interface else '' }}{{ livekit_server_config_rtc_port_range_start }}-{{ livekit_server_config_rtc_port_range_end }}:{{ livekit_server_config_rtc_port_range_start }}-{{ livekit_server_config_rtc_port_range_end }}/udp \
  40. {% endif %}
  41. {% if livekit_server_container_rtc_listen_interface is not in [none, 'none'] and livekit_server_config_rtc_udp_port %}
  42. -p {{ livekit_server_container_rtc_listen_interface }}{{ ':' if livekit_server_container_rtc_listen_interface else '' }}{{ livekit_server_config_rtc_udp_port }}:{{ livekit_server_config_rtc_udp_port }}/udp \
  43. {% endif %}
  44. {% if livekit_server_container_turn_listen_interface is not in [none, 'none'] and livekit_server_config_turn_enabled %}
  45. -p {{ livekit_server_container_turn_listen_interface }}{{ ':' if livekit_server_container_turn_listen_interface else '' }}{{ livekit_server_config_turn_tls_port }}:{{ livekit_server_config_turn_tls_port }} \
  46. {% endif %}
  47. {% if livekit_server_container_turn_listen_interface is not in [none, 'none'] and livekit_server_config_turn_enabled %}
  48. -p {{ livekit_server_container_turn_listen_interface }}{{ ':' if livekit_server_container_turn_listen_interface else '' }}{{ livekit_server_config_turn_udp_port }}:{{ livekit_server_config_turn_udp_port }}/udp \
  49. {% endif %}
  50. {% if livekit_server_container_metrics_listen_interface is not in [none, 'none'] and livekit_server_config_prometheus_enabled %}
  51. -p {{ livekit_server_container_metrics_listen_interface }}{{ ':' if livekit_server_container_metrics_listen_interface else '' }}{{ livekit_server_config_prometheus_port }}:{{ livekit_server_config_prometheus_port }} \
  52. {% endif %}
  53. {% if livekit_server_container_http_host_bind_port %}
  54. -p {{ livekit_server_container_http_host_bind_port }}:{{ livekit_server_config_port }} \
  55. {% endif %}
  56. --env-file={{ livekit_server_base_path }}/env \
  57. --label-file={{ livekit_server_base_path }}/labels \
  58. --mount type=bind,src={{ livekit_server_config_path }}/config.yaml,dst=/livekit-config.yaml,ro \
  59. {% for volume in livekit_server_container_additional_volumes %}
  60. --mount type={{ volume.type | default('bind' if '/' in volume.src else 'volume') }},src={{ volume.src }},dst={{ volume.dst }}{{ (',' + volume.options) if volume.options else '' }} \
  61. {% endfor %}
  62. {{ livekit_server_container_image_self_build_name if livekit_server_container_image_self_build else livekit_server_container_image }} \
  63. --config /livekit-config.yaml
  64. {% for network in livekit_server_container_additional_networks %}
  65. ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} {{ livekit_server_identifier }}
  66. {% endfor %}
  67. ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach {{ livekit_server_identifier }}
  68. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop -t {{ devture_systemd_docker_base_container_stop_grace_time_seconds }} {{ livekit_server_identifier }} 2>/dev/null || true'
  69. ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm {{ livekit_server_identifier }} 2>/dev/null || true'
  70. Restart=always
  71. RestartSec=30
  72. SyslogIdentifier={{ livekit_server_identifier }}
  73. [Install]
  74. WantedBy=multi-user.target