From a22d96251ab6ceb8772b47d51609fb22b5ae9fe6 Mon Sep 17 00:00:00 2001 From: Bas Meijer Date: Thu, 21 Nov 2024 21:18:50 +0100 Subject: [PATCH] Extended Systemd Service --- roles/semaphore/tasks/present.yml | 18 +----------------- roles/semaphore/templates/semaphore.service.j2 | 13 ++++++++++++- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/roles/semaphore/tasks/present.yml b/roles/semaphore/tasks/present.yml index f48549a..dafab41 100644 --- a/roles/semaphore/tasks/present.yml +++ b/roles/semaphore/tasks/present.yml @@ -99,7 +99,7 @@ - "{{ semaphore_config_dir }}" - /home/semaphore/tmp -- name: Copy requirements +- name: Copy requirements for ExecStartPre ansible.builtin.copy: src: "{{ item }}" dest: /home/semaphore/ @@ -110,22 +110,6 @@ - requirements.txt - requirements.yml -- name: Install requirements for semaphore user - become: true - become_user: semaphore - ansible.builtin.pip: - requirements: '/home/semaphore/requirements.txt' - executable: /usr/bin/pip3.12 - extra_args: '--user' - state: present - -- name: Install collections - become: true - become_user: semaphore - ansible.builtin.command: - cmd: ansible-galaxy collection install -r /home/semaphore/requirements.yml - changed_when: true - - name: Deploy Semaphore Config become: true ansible.builtin.template: diff --git a/roles/semaphore/templates/semaphore.service.j2 b/roles/semaphore/templates/semaphore.service.j2 index 3871582..6d68eb3 100644 --- a/roles/semaphore/templates/semaphore.service.j2 +++ b/roles/semaphore/templates/semaphore.service.j2 @@ -1,18 +1,29 @@ [Unit] Description=Semaphore UI +Documentation=https://github.com/semaphoreui/semaphore Requires=network.target After=network.target syslog.target -Documentation=https://github.com/semaphoreui/semaphore +ConditionPathExists=/usr/bin/semaphore +ConditionPathExists=/etc/semaphore/config.json [Service] User=semaphore Group=semaphore +Environment=LANG="en_US.UTF-8" +Environment=LC_ALL="en_US.UTF-8" +Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/.local/bin" ExecStart=/usr/bin/semaphore server --config /etc/semaphore/config.json ExecStop=/bin/kill -s QUIT $MAINPID ExecReload=/bin/kill -s HUP $MAINPID Restart=always RestartSec=25s WorkingDirectory=/home/semaphore +StandardOutput=journal +StandardError=journal +SyslogIdentifier=semaphore + +ExecStartPre=/bin/bash -c 'pip3.12 install --upgrade --user -r /home/semaphore/requirements.txt' +ExecStartPre=/bin/bash -c 'ansible-galaxy collection install --upgrade -r /home/semaphore/requirements.yml' [Install] WantedBy=multi-user.target