I’m trying to create an autostart service for my python-flask-socketio server.
I need to start a python script through systemd. Here’s my service code:
[Unit] Description=AppName [Service] Type=forking ExecStart=/usr/bin/python3 /opt/myapp/app.py [Install] WantedBy=multi-user.target
If I try to start it manually using
sudo service myservice start – it works just fine. It halts my terminalssh window but I can close it and it works like expected.
But when I reboot my PC it does not start. When checking it’s status with
systemctl status myservice I get the following:
systemd: Starting My Service... systemd: myserivce.service: Start operation timed out. Terminating. systemd: Failed to start My Service. systemd: myserivce.service: Unit entered failed state. systemd: myserivce.service: Failed with result 'timeout'.
What am I doing wrong here?
Your type seems wrong, forking is for programs that detach immediately by themselves. Flask does not, it stays attached to your console.
Your service type should probably be