Я хочу автоматически запустить мой скрипт с помощью systemd, который выполняет git checkout, git pull (я уверен, что конфликт не возникнет), а после этого запускает программу на python.Я создал пример, который показывает мою задачу.Но периодически вылетает.Правильно ли установить «TimeoutStartSec = infinity»?Возможно, я должен сделать это по-другому?
TEST_DAEMON.py
#!/usr/bin/python3.7
while True:
pass
TEST_DAEMON.sh
#!/bin/sh
cd /home/user/TEST_DAEMON/
git checkout master
git pull
/home/user/TEST_DAEMON/TEST_DAEMON.py
TEST_DAEMON.service
[Unit]
Description=TEST_DAEMON SERVICE
[Install]
WantedBy=multi-user.target
[Service]
Type=forking
User=user
PIDFile=/var/run/test_daemon.pid
WorkingDirectory=/home/user/TEST_DAEMON
ExecStart=/home/user/TEST_DAEMON/TEST_DAEMON.py
Restart=always
=========================================
sudo systemctl status TEST_DAEMON.service
● TEST_DAEMON.service - TEST_DAEMON SERVICE
Loaded: loaded (/etc/systemd/system/TEST_DAEMON.service; enabled; vendor preset: enabled)
Active: activating (start) since Thu 2019-06-13 10:11:01 MSK; 2min 26s ago
Cntrl PID: 7699 (TEST_DAEMON.sh)
Tasks: 2 (limit: 4915)
CGroup: /system.slice/TEST_DAEMON.service
├─7699 /bin/sh /home/user/TEST_DAEMON/TEST_DAEMON.sh
└─7713 /usr/bin/python3.7 /home/user/TEST_DAEMON/TEST_DAEMON.py
Part of log "journalctl -u TEST_DAEMON.service"
Jun 11 15:36:39 TEST_DAEMON.sh[30119]: Already on 'agents_manager'
Jun 11 15:36:39 TEST_DAEMON.sh[30119]: Your branch is up to date with 'origin/agents_manager'.
Jun 11 15:36:42 TEST_DAEMON.sh[30119]: Already up to date.
Jun 11 15:38:10 systemd[1]: TEST_DAEMON.service: Start operation timed out. Terminating.
Jun 11 15:38:10 systemd[1]: TEST_DAEMON.service: Failed with result 'timeout'.
Jun 11 15:38:10 systemd[1]: Failed to start TEST_DAEMON SERVICE.
Jun 11 15:38:10 systemd[1]: TEST_DAEMON.service: Service hold-off time over, scheduling restart.
Jun 11 15:38:10 systemd[1]: TEST_DAEMON.service: Scheduled restart job, restart counter is at 3.
Jun 11 15:38:10 systemd[1]: Stopped TEST_DAEMON SERVICE.
Jun 11 15:38:10 systemd[1]: Starting TEST_DAEMON SERVICE...
Jun 11 15:38:10 TEST_DAEMON.sh[30227]: Already on 'agents_manager'
Jun 11 15:38:10 TEST_DAEMON.sh[30227]: Your branch is up to date with 'origin/agents_manager'.
Jun 11 15:38:15 TEST_DAEMON.sh[30227]: Already up to date.
Jun 11 15:39:40 systemd[1]: TEST_DAEMON.service: Start operation timed out. Terminating.
Jun 11 15:39:40 systemd[1]: TEST_DAEMON.service: Failed with result 'timeout'.
Jun 11 15:39:40 systemd[1]: Failed to start TEST_DAEMON SERVICE.
Jun 11 15:39:40 systemd[1]: TEST_DAEMON.service: Service hold-off time over, scheduling restart.
Jun 11 15:39:40 systemd[1]: TEST_DAEMON.service: Scheduled restart job, restart counter is at 4.
Jun 11 15:39:40 systemd[1]: Stopped TEST_DAEMON SERVICE.
Jun 11 15:39:40 systemd[1]: Starting TEST_DAEMON SERVICE...
Jun 11 15:39:40 TEST_DAEMON.sh[30273]: Already on 'agents_manager'
Jun 11 15:39:40 TEST_DAEMON.sh[30273]: Your branch is up to date with 'origin/agents_manager'.
Jun 11 15:39:43 TEST_DAEMON.sh[30273]: Already up to date.