Files
mGPUmanager/Makefile
mAi 167999cecf build: deploy as systemd --user unit on mRock
Convention on mRock is user-units for ML services (whisper-server,
mvoice-launcher, comfyui as of today). Switching mGPUmanager too:

- systemd/mgpumanager.service: rewritten as a user unit (%h-based
  WorkingDirectory + ExecStart, WantedBy=default.target). Drops the
  ProtectSystem/ProtectHome hardening that came from the system-unit
  template — user units don't need it, and ProtectHome=read-only
  blocks a user unit's own working dir.
- Makefile deploy target: rsync to ~/.config/systemd/user/ on the
  remote and use systemctl --user, no sudo. README documents the
  lingering prerequisite (loginctl enable-linger m).
- config/consumers.yaml: bind on 0.0.0.0:8770 instead of localhost so
  mRiver / Tailscale peers can actually reach the broker.

Refs: m/mGPUmanager#1 (deploy task).
2026-05-15 16:50:04 +02:00

39 lines
1.3 KiB
Makefile

# mGPUmanager build + deploy targets.
#
# `make build` — compile the Go binary into ./bin/mgpumanager.
# `make test` — go test ./...
# `make run` — run locally against ./config/consumers.yaml.
# `make deploy` — rsync binary + config + user-unit to mRock and
# (re)start it under `systemctl --user`.
BIN := bin/mgpumanager
PKG := ./cmd/mgpumanager
GO ?= go
HOST ?= mrock
REMOTE_DIR ?= /home/m/dev/mGPUmanager
USER_UNIT_DIR ?= /home/m/.config/systemd/user
.PHONY: build test run deploy clean
build:
mkdir -p bin
$(GO) build -trimpath -ldflags="-s -w" -o $(BIN) $(PKG)
test:
$(GO) test ./...
run: build
./$(BIN) --config config/consumers.yaml --log-level debug
# Deploys to mRock as a user unit (systemd --user). User lingering must
# be enabled on the target host: `sudo loginctl enable-linger m`.
deploy: build
rsync -a --mkpath $(BIN) $(HOST):$(REMOTE_DIR)/$(BIN)
rsync -a --mkpath config/consumers.yaml $(HOST):$(REMOTE_DIR)/config/consumers.yaml
rsync -a --mkpath systemd/mgpumanager.service $(HOST):$(USER_UNIT_DIR)/mgpumanager.service
ssh $(HOST) "systemctl --user daemon-reload && systemctl --user enable mgpumanager.service && systemctl --user restart mgpumanager.service && systemctl --user status mgpumanager.service --no-pager -l"
clean:
rm -rf bin