Ubuntu Setup Guide¶
This guide walks you through installing the MicroDC Worker on Ubuntu as a systemd service.
Prerequisites¶
- Ubuntu 20.04 LTS or newer (22.04/24.04 recommended)
- Root/sudo access
- Python 3.8 or higher (3.10+ recommended)
- Internet connection for downloading dependencies
Quick Install¶
# Clone the worker repository
git clone https://gitlab.com/microdc/worker.git
cd microhub_worker
# Run the automated setup script
sudo ./ubuntu_setup.sh
The script will:
- Install system dependencies (Python 3.12, git, curl) and uv (installed
system-wide to
/usr/local/bin) - Create a dedicated service user (
microdcworker) - Set up the installation directory at
/srv/microdcworker - Create the virtual environment with
uv venv --seed - Install Python dependencies with
uv pip install - Configure the systemd service with security hardening
- Create configuration templates
Re-running
sudo ./ubuntu_setup.shon an existing install is safe — it migrates an older pip/venv deployment to uv in place (stopping the service first and restarting it after).
Optional components¶
The installer can also provision two opt-in components (prompted interactively, or via flags):
| Flag | What it does |
|---|---|
sudo ./ubuntu_setup.sh --with-vllm |
Installs a dedicated vLLM env at /srv/microdcworker/vllm-env (Python 3.12, large CUDA download — GPU hosts only) for the native vLLM engine. |
sudo ./ubuntu_setup.sh --with-podman |
Sets up Podman for container / container_stream jobs. Equivalent standalone script: sudo ./setup_podman.sh. |
Tip: generate a hardware-tuned
worker.yamlinstead of hand-editing the reference config withpython scripts/generate_config.py(see the config wizard).
Post-Installation Configuration¶
1. Configure API Credentials¶
Edit the environment file with your API key:
Set the required values:
# Server connection (REQUIRED)
MICRODC_SERVER_URL=https://api.microdc.ai
MICRODC_API_KEY=mdc_wrk_xxxxx # Your API key from MicroDC console
2. Configure Inference Engine¶
The worker needs an inference engine to process jobs. Ollama is recommended:
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Start Ollama
sudo systemctl enable ollama
sudo systemctl start ollama
# Pull a model
ollama pull llama3.1:8b
Update the environment file with Ollama settings:
3. Start the Worker¶
# Start the service
sudo systemctl start microdcworker
# Enable auto-start on boot
sudo systemctl enable microdcworker
# Verify it's running
sudo systemctl status microdcworker
Service Management¶
| Command | Description |
|---|---|
sudo systemctl start microdcworker |
Start the worker |
sudo systemctl stop microdcworker |
Stop the worker |
sudo systemctl restart microdcworker |
Restart the worker |
sudo systemctl status microdcworker |
Check status |
sudo journalctl -u microdcworker -f |
View live logs |
sudo journalctl -u microdcworker --since "1 hour ago" |
View recent logs |
Directory Structure¶
After installation, the directory structure is:
/srv/microdcworker/
├── config/
│ ├── worker.yaml # Main configuration file
│ └── environment # Environment variables (API keys)
├── src/ # Application source code
├── venv/ # Virtual environment (created by uv)
├── vllm-env/ # Dedicated vLLM env (only with --with-vllm)
├── uv-python/ # uv-managed Python interpreters (e.g. 3.12 for vLLM)
├── .cache/ # uv / model caches (kept inside the hardened unit)
├── logs/ # Application logs
├── backups/ # Auto-update backups (only when auto-update is enabled)
├── requirements.txt # Python dependencies
└── setup.py # Package setup
Configuration Files¶
Environment File (/srv/microdcworker/config/environment)¶
# Required Settings
MICRODC_SERVER_URL=https://api.microdc.ai
MICRODC_API_KEY=your_api_key_here
# Engine Configuration
MICRODC_ENGINE=ollama
OLLAMA_BASE_URL=http://localhost:11434
# Optional: Worker Identification
WORKER_ID=worker-1
WORKER_NAME=My Worker
WORKER_ORG=default
# Optional: Auto-Update (DISABLED by default — opt in to enable)
# AUTO_UPDATE_ENABLED=true
# UPDATE_CHECK_INTERVAL=21600 # 6 hours
# Optional: Logging
LOG_LEVEL=INFO
HEARTBEAT_INTERVAL=30
Worker Config (/srv/microdcworker/config/worker.yaml)¶
The YAML config file provides additional options. See config/default.yaml for all available settings.
GPU Support¶
NVIDIA GPU¶
# Verify GPU is detected
nvidia-smi
# The worker automatically detects NVIDIA GPUs
# No additional configuration needed
No GPU (CPU Only)¶
The worker runs fine on CPU-only systems. Ensure your pulled models are appropriate for CPU inference:
Firewall Configuration¶
If you have a firewall enabled, ensure the worker can reach:
- Your MicroDC server (default: port 443 for HTTPS)
- Ollama (default: localhost:11434)
Troubleshooting¶
Worker Won't Start¶
- Check the logs:
- Verify configuration:
- Test manually:
Authentication Errors¶
- Verify your API key is correct
- Check the server URL is reachable:
- Credentials are saved in
~/.microdc/worker_credentials.jsonafter first successful registration
Ollama Connection Issues¶
- Verify Ollama is running:
- Check if models are available:
Permission Issues¶
The service runs as the microdcworker user. Ensure file permissions are correct:
sudo chown -R microdcworker:microdcworker /srv/microdcworker
sudo chmod 750 /srv/microdcworker/config
sudo chmod 640 /srv/microdcworker/config/environment
Updating the Worker¶
Auto-update is disabled by default. The recommended way to update is to pull the latest code and re-run the installer (it migrates the venv and restarts the service):
Enable Auto-Update (opt-in)¶
If you want the worker to check for and apply updates automatically (every 6 hours, with backup/rollback), edit the environment file:
Uninstalling¶
# Stop and disable the service
sudo systemctl stop microdcworker
sudo systemctl disable microdcworker
# Remove systemd service file
sudo rm /etc/systemd/system/microdcworker.service
sudo systemctl daemon-reload
# Remove installation directory
sudo rm -rf /srv/microdcworker
# Remove service user (optional)
sudo userdel -r microdcworker
Security Notes¶
The systemd service includes security hardening:
- NoNewPrivileges: Prevents privilege escalation
- PrivateTmp: Isolated temporary directory
- ProtectSystem: Read-only system directories
- ProtectHome: No access to home directories
- ReadWritePaths: Only
/srv/microdcworkeris writable
Keep your API key secure and never commit it to version control.