-
Notifications
You must be signed in to change notification settings - Fork 0
Systemd Hosting
Ivole32 edited this page Sep 30, 2025
·
1 revision
This guide explains how to run Linux-API as a systemd service for production use on Linux.
- Linux system with systemd
- Python 3.11+ and all dependencies installed
- Linux-API installed (see pip-hosting guide)
You can run Linux-API as a service in two ways:
Create a file /etc/systemd/system/linux-api.service with the following content:
[Unit]
Description=Linux-API Server (with start.sh)
After=network.target
[Service]
Type=simple
User=linuxapi
WorkingDirectory=/path/to/Linux-API
ExecStart=/bin/bash ./start.sh
Restart=on-failure
[Install]
WantedBy=multi-user.targetCreate a file /etc/systemd/system/linux-api.service with the following content:
[Unit]
Description=Linux-API Server (direct command)
After=network.target
[Service]
Type=simple
User=linuxapi
WorkingDirectory=/path/to/Linux-API
ExecStart=/usr/bin/python3 -m uvicorn linux_api.server:app --host 0.0.0.0 --port 8000
Restart=on-failure
[Install]
WantedBy=multi-user.target- Replace
/path/to/Linux-APIwith your actual project path. - Set
User=to a dedicated user (recommended for security).
-
Reload systemd:
sudo systemctl daemon-reload
-
Enable the service:
sudo systemctl enable linux-api -
Start the service:
sudo systemctl start linux-api
-
Check status:
sudo systemctl status linux-api
- Logs are available via
journalctl -u linux-api. - The admin API key is printed to the service log on first start.