First, build the worker binary:
cd /path/to/transcode-worker
go build -o bin/worker cmd/worker/main.goCopy and edit the configuration file:
cp config-example.yml config.yml
nano config.ymlUpdate the following settings:
orchestrator_url: "http://192.168.1.100:8080" # Your orchestrator IP
nas_mount_path: "/mnt/nas" # Your NAS mount point
temp_dir: "/tmp/transcode-worker" # Fast local storage
worker_id: "" # Leave empty to use hostname
sync_interval: 10s # How often to sync with orchestrator
log_level: "info"Create a systemd service file:
sudo nano /etc/systemd/system/transcode-worker.servicePaste the following configuration:
[Unit]
Description=Transcode Worker Service
Documentation=https://github.com/ArthurCRodrigues/transcode-worker
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=your_username
Group=your_username
WorkingDirectory=/path/to/transcode-worker
ExecStart=/path/to/transcode-worker/bin/worker
# Environment variables (optional - can also use config.yml)
Environment="WORKER_ORCHESTRATOR_URL=http://192.168.1.100:8080"
Environment="WORKER_NAS_MOUNT_PATH=/mnt/nas"
Environment="WORKER_TEMP_DIR=/tmp/transcode-worker"
# Restart configuration
Restart=always
RestartSec=10
# Resource limits (optional but recommended)
LimitNOFILE=65536
Nice=10
# Logging
StandardOutput=journal
StandardError=journal
SyslogIdentifier=transcode-worker
[Install]
WantedBy=multi-user.targetImportant: Replace:
your_usernamewith your actual username/path/to/transcode-workerwith the actual path
# Reload systemd to recognize the new service
sudo systemctl daemon-reload
# Enable the service to start on boot
sudo systemctl enable transcode-worker
# Start the service
sudo systemctl start transcode-worker
# Check the status
sudo systemctl status transcode-workerCheck the logs to ensure the worker registered successfully:
# View recent logs
sudo journalctl -u transcode-worker -n 50
# Follow logs in real-time
sudo journalctl -u transcode-worker -f
# Filter by time
sudo journalctl -u transcode-worker --since "5 minutes ago"You should see output like:
Starting transcode worker: your-hostname
Orchestrator URL: http://192.168.1.100:8080
NAS Mount Path: /mnt/nas
Registering with orchestrator...
Successfully registered as worker: your-hostname
Starting heartbeat loop (interval: 10s)
Starting job polling loop...
# Stop the worker
sudo systemctl stop transcode-worker
# Restart the worker
sudo systemctl restart transcode-worker
# Disable auto-start on boot
sudo systemctl disable transcode-worker
# View service configuration
sudo systemctl cat transcode-worker
# Check if service is enabled
sudo systemctl is-enabled transcode-worker