I created a shell script for start my fastapi server which located in my-dir. It works properly when I run it with ./script.sh
. Server runs.
#!/bin/bash
poetry run python main.py
Now I want to create a daemon unit for it. I created him in /etc/systemd/system/gunicorn.service but it doesn’t work. I see an error when I check sudo systemctl status gunicorn
[Unit]
Description=gunicorn daemon for FastAPI app
After=network.target
[Service]
User=root
Group=www-data
WorkingDirectory=/root/my-dir
ExecStart=/root/my-dir/script.sh
Restart=on-failure
[Install]
WantedBy=multi-user.target
Active: failed (Result: exit-code) since Fri 2024-07-12 11:39:47 MSK; 9min ago
Process: 28744 ExecStart=/root/my-dir/script.sh (code=exited, status=127)
Main PID: 28744 (code=exited, status=127)
Jul 12 11:39:47 vm2762852 systemd[1]: gunicorn.service: Scheduled restart job, restart counter is at 5.
Jul 12 11:39:47 vm2762852 systemd[1]: Stopped gunicorn daemon for FastAPI app.
Jul 12 11:39:47 vm2762852 systemd[1]: gunicorn.service: Start request repeated too quickly.
How I can fix it?