Add c2.service unit to run the FastAPI app as workshop-c2. The unit invokes uv via /usr/bin/env, sets PATH and PYTHONUNBUFFERED, enables automatic restarts with a short backoff, and logs to the journal using SyslogIdentifier. Also update main.py's runtime invocation
28 lines
754 B
Desktop File
28 lines
754 B
Desktop File
[Unit]
|
|
Description=Workshop C2 FastAPI service
|
|
After=network.target
|
|
|
|
[Service]
|
|
Type=simple
|
|
WorkingDirectory=/home/kemp/ins/teaching/workshop-c-and-c-server
|
|
# Run the requested command. This uses /usr/bin/env to locate `uv` in PATH.
|
|
ExecStart=/usr/bin/env uv run main.py
|
|
# Ensure common system paths are available when using /usr/bin/env
|
|
Environment=PATH=/usr/local/bin:/usr/bin:/bin
|
|
Environment=PYTHONUNBUFFERED=1
|
|
|
|
# Automatically restart the process if it exits/crashes
|
|
Restart=always
|
|
RestartSec=5
|
|
|
|
# Log to the journal/syslog with a clear identifier
|
|
StandardOutput=journal
|
|
StandardError=journal
|
|
SyslogIdentifier=workshop-c2
|
|
|
|
# (Optional) Uncomment and set a non-root user if desired
|
|
#User=www-data
|
|
#Group=www-data
|
|
|
|
[Install]
|
|
WantedBy=multi-user.target
|