The restart can be automated, no interaction required.
I tried with this super useful program.
$ cat/home/xabbu/test22/main.py
import time
while (True):
print ("test")
time.sleep(5)
$ cat test.service
[Unit]
Description=Start scripts
After=network.target
Requires=network-online.target
[Service]
Type=forking
ExecStart=/usr/bin/tmux new-session -d -s 0 'cd /home/xabbu/test22 && python main.py'
[Install]
WantedBy=multi-user.target
$ systemctl status test.service
● test.service - Start scripts
Loaded: loaded (/etc/systemd/system/test.service; disabled; vendor preset: disabled)
Active: active (running) since Sat 2022-03-26 19:21:54 CET; 5min ago
Process: 19502 ExecStart=/usr/bin/tmux new-session -d -s 0 cd /home/xabbu/test22 && python main.py (code=exited, status=0/SUCCESS)
Main PID: 19504 (tmux: server)
Tasks: 2 (limit: 2349)
Memory: 4.6M
CPU: 48ms
CGroup: /system.slice/test.service
├─19504 /usr/bin/tmux new-session -d -s 0 "cd /home/xabbu/test22 && python main.py"
└─19505 python main.py
Mar 26 19:21:54 arch.vir systemd[1]: Starting Start scripts...
Mar 26 19:21:54 arch.vir systemd[1]: Started Start scripts.
Work with my little python script. Since it will run as root, are you sure all permissions are correct? Did you started it before as root or as your normal user.