From d9e0d2969362d047393b2e520d7ade5c91c04275 Mon Sep 17 00:00:00 2001 From: Tobias Werth Date: Sun, 12 May 2024 11:00:44 +0200 Subject: [PATCH] Use systemd to start domlogo (#135) * Use systemd to start domlogo * Update provision-contest/ansible/roles/domlogo/templates/domlogo.service.j2 Co-authored-by: MCJ Vasseur <14887731+vmcj@users.noreply.github.com> --------- Co-authored-by: DOMjudge team Co-authored-by: MCJ Vasseur <14887731+vmcj@users.noreply.github.com> --- .../ansible/roles/domlogo/tasks/main.yml | 15 +++++++++------ .../domlogo/templates/domjudgelogo.desktop.j2 | 4 ---- .../roles/domlogo/templates/domlogo.service.j2 | 18 ++++++++++++++++++ 3 files changed, 27 insertions(+), 10 deletions(-) delete mode 100644 provision-contest/ansible/roles/domlogo/templates/domjudgelogo.desktop.j2 create mode 100644 provision-contest/ansible/roles/domlogo/templates/domlogo.service.j2 diff --git a/provision-contest/ansible/roles/domlogo/tasks/main.yml b/provision-contest/ansible/roles/domlogo/tasks/main.yml index 705db5d8..f5811239 100644 --- a/provision-contest/ansible/roles/domlogo/tasks/main.yml +++ b/provision-contest/ansible/roles/domlogo/tasks/main.yml @@ -44,10 +44,13 @@ owner: domjudge group: domjudge -- name: Add autostart shortcuts +- name: Copy domlogo systemd unit file template: - src: "domjudgelogo.desktop.j2" - dest: "/home/domjudge/.config/autostart/domjudgelogo.desktop" - owner: domjudge - group: domjudge - mode: 0755 + src: "domlogo.service.j2" + dest: "/etc/systemd/system/domlogo.service" + +- name: Enable and start domlogo + systemd: + name: domlogo + enabled: true + state: started \ No newline at end of file diff --git a/provision-contest/ansible/roles/domlogo/templates/domjudgelogo.desktop.j2 b/provision-contest/ansible/roles/domlogo/templates/domjudgelogo.desktop.j2 deleted file mode 100644 index 03e4e0bc..00000000 --- a/provision-contest/ansible/roles/domlogo/templates/domjudgelogo.desktop.j2 +++ /dev/null @@ -1,4 +0,0 @@ -[Desktop Entry] -Name=domjudgelogo -Type=Application -Exec=bash -c "sleep 10 && cd {{ DJ_DIR }} && while true; do python3 ./domlogo.py 1>>/home/domjudge/logo.out 2>>/home/domjudge/logo.err; sleep 2; done" diff --git a/provision-contest/ansible/roles/domlogo/templates/domlogo.service.j2 b/provision-contest/ansible/roles/domlogo/templates/domlogo.service.j2 new file mode 100644 index 00000000..71c899e3 --- /dev/null +++ b/provision-contest/ansible/roles/domlogo/templates/domlogo.service.j2 @@ -0,0 +1,18 @@ +[Unit] +Description="DOMlogo" +After=network.target + +[Service] +Type=simple + +Environment=REQUESTS_CA_BUNDLE=/usr/local/share/ca-certificates/domserver.crt +Environment=DISPLAY=:0 +WorkingDirectory={{ DJ_DIR }} +ExecStart=domlogo.py +User=domjudge + +Restart=always +RestartSec=3 + +[Install] +WantedBy=graphical.target