diff --git a/roles/matrix-bridge-appservice-kakaotalk/templates/systemd/matrix-appservice-kakaotalk-node.service.j2 b/roles/matrix-bridge-appservice-kakaotalk/templates/systemd/matrix-appservice-kakaotalk-node.service.j2 index 6f6e66341..ef004b488 100644 --- a/roles/matrix-bridge-appservice-kakaotalk/templates/systemd/matrix-appservice-kakaotalk-node.service.j2 +++ b/roles/matrix-bridge-appservice-kakaotalk/templates/systemd/matrix-appservice-kakaotalk-node.service.j2 @@ -28,8 +28,12 @@ ExecStart={{ matrix_host_command_docker }} run --rm --name matrix-appservice-kak -v {{ matrix_appservice_kakaotalk_data_path }}:/data:z \ {{ matrix_appservice_kakaotalk_node_docker_image }} +ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill --signal=TERM matrix-appservice-kakaotalk-node 2>/dev/null || true' +# Intentional delay so that the container has time to stop gracefully and remove the RPC socket. +ExecStop=-{{ matrix_host_command_sleep }} 5 ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} kill matrix-appservice-kakaotalk-node 2>/dev/null || true' ExecStop=-{{ matrix_host_command_sh }} -c '{{ matrix_host_command_docker }} rm matrix-appservice-kakaotalk-node 2>/dev/null || true' +ExecStop=-{{ matrix_host_command_sh }} -c 'rm {{ matrix_appservice_kakaotalk_data_path }}/rpc.sock 2>/dev/null || true' Restart=always RestartSec=30