LiteLLM Docker Compose System Integration
This document explains the usage and logic of the deploy-litellm-systemd.sh script, which installs and configures a systemd unit to automatically start a Docker Compose stack for LiteLLM on system boot.
๐ Script Overview
The script performs the following:
- Validates necessary paths, binaries, and user presence.
- Generates a systemd unit file for Docker Compose-based service.
- Enables the unit for autostart on boot.
- Uses
qcuseras the execution user for the service. - Must be configured by root or sudo user.
๐งน Prerequisites
Ensure the following:
- Docker is installed and available at
/usr/bin/docker - The Docker Compose project is located at:
/home/qcuser/litellm/ - The
qcuseruser exists and owns the project folder - Systemd is present (all Debian/Ubuntu systems have it)
๐ Directory Structure
Expected directory layout:
/home/qcuser/litellm/
โโโ docker-compose.yml
โโโ other-compose-files.yml (optional)
โ๏ธ Script Content and Explanation
#!/bin/bash
set -e
set -e: Exit immediately if any command fails.
๐ง Configuration Variables
SERVICE_NAME="litellm-root.service"
SERVICE_PATH="/etc/systemd/system/$SERVICE_NAME"
COMPOSE_DIR="/home/qcuser/litellm"
DOCKER_COMPOSE_BIN="/usr/bin/docker"
Defines systemd service name, its path, working directory, and the Docker binary location.
โ Checks
if [ ! -d "$COMPOSE_DIR" ]; then ...
- Verifies the Docker Compose project directory exists.
- Checks if
qcuserexists. - Confirms Docker binary is accessible.
โ ๏ธ Overwrite Confirmation
if [ -f "$SERVICE_PATH" ]; then ...
- If the unit already exists, prompts the user before overwriting it.
๐ systemd Unit Creation
Creates a unit file with docker compose up -d as the ExecStart and docker compose down as the ExecStop.
[Unit]
Description=LiteLLM Docker Compose Autostart
After=network.target docker.service
Requires=docker.service
[Service]
Type=oneshot
WorkingDirectory=/home/qcuser/litellm
ExecStart=/usr/bin/docker compose up -d
ExecStop=/usr/bin/docker compose down
RemainAfterExit=true
User=qcuser
Group=qcuser
[Install]
WantedBy=multi-user.target
๐ Enable and Reload systemd
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable "$SERVICE_NAME"
Reloads systemd configuration and enables the unit for autostart.
๐ Final Output
Systemd unit litellm-root.service is ready and enabled for autostart.
Current running containers will not be affected.
Confirms that the unit is ready and won't interrupt currently running containers.
๐ฅช Usage
To start the service:
sudo systemctl start litellm-root.service
To stop the service:
sudo systemctl stop litellm-root.service
To check status:
systemctl status litellm-root.service
To view logs:
journalctl -u litellm-root.service
Changelog
| Date | Author | Message |
|---|---|---|
| 2026-02-25 | aresnikowa | Merge remote-tracking branch 'origin/master' |