Quantcast
Channel: Active questions tagged ubuntu - Stack Overflow
Viewing all articles
Browse latest Browse all 5956

How to automatically restart FastAPI server on Ubuntu after system reboot? [closed]

$
0
0

I'm encountering an issue with my FastAPI server running on Ubuntu. Every time the server reboots (possibly due to a DDOS attack), the FastAPI service goes down and requires manual restart. This causes downtime and often leads to errors until I realize the server has rebooted.

Is there a way to configure FastAPI or Ubuntu to automatically restart the FastAPI service upon system reboot? I want to ensure seamless operation even after unexpected server reboots.

Any help or guidance would be greatly appreciated. Thank you!"

P/s: I start FastAPI server in a seperate screen

[Updated]I try to create a system service named fastapi.service, but when I run

systemctl start fastapi

It throws the error:

systemd[1]: fastapi.service: Main process exited, code=exited, status=217/USERsystemd[1]: fastapi.service: Failed with result 'exit-code'.systemd[1]: fastapi.service: Scheduled restart job, restart counter is at 5.systemd[1]: Stopped FastAPI Service.systemd[1]: fastapi.service: Start request repeated too quickly.systemd[1]: fastapi.service: Failed with result 'exit-code'.systemd[1]: Failed to start FastAPI Service.

I set TimeoutStartSec=1m or TimeoutSec=60 but it does not effect


Viewing all articles
Browse latest Browse all 5956

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>