I have the following systemd service to run my flask app:
[Unit]
Description=My Flask server
After=network.target
[Service]
User=ubuntu
ExecStart=/home/ubuntu/my-server/script.py
WorkingDirectory=/home/ubuntu/my-server/
Restart=on-failure
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
However, when I run
systemctl start my-server.service
I get the following status
my-server.service - My Flask server
Loaded: loaded (/etc/systemd/system/my-server.service; enabled; vendor preset: enabled)
Active: active (exited) (Result: exit-code) since Wed 2017-06-21 22:24:18 UTC; 8min ago
Main PID: 8407
(code=exited, status=203/EXEC)
How do I prevent the Flask server from exiting? When I run the script directly with
/home/ubuntu/my-server/script.py
it works fine. But if I run it with systemd, the server exits immediately.