Deploying Web Applications & Monitoring Web Apps
pip install watchdog
https://pypi.org/project/watchdog/
Instead of running a background process in a tmux session on a remote server for persistence, can also create a system daemon, which might be essentially the same thing, although slightly different way of going about, and there might be some differences due to how tmux is implemented. A daemon is a background process.
run a systemd service
- create a file with vim or an editor of choice
sudo nano /etc/systemd/system/fastapi.service
These are the specifications that go in to the file, i.e. the configurations.
- [Unit] Description=FastAPI Application
- After=network.target [Service]
- User=your-user
- WorkingDirectory=/path/to/your/app
- ExecStart=/usr/bin/env uvicorn app:app — host 0.0.0.0 — port 8000
- Restart=always[Install]
- WantedBy=multi-user.target
[Unit] Description=FastAPI Application After=network.target [Service] User=your-user WorkingDirectory=/path/to/your/app ExecStart=/usr/bin/env uvicorn app:app --host 0.0.0.0 --port 8000 Restart=always [Install] WantedBy=multi-user.target
Enable and start the service via command line
sudo systemctl enable fastapi sudo systemctl start fastapi