Issue
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 terminal\ssh 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[1]: Starting My Service...
systemd[1]: myserivce.service: Start operation timed out. Terminating.
systemd[1]: Failed to start My Service.
systemd[1]: myserivce.service: Unit entered failed state.
systemd[1]: myserivce.service: Failed with result 'timeout'.
What am I doing wrong here?
Solution
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 simple
Answered By - Anthony Rossi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.