Enhance CLI options and idle-killer functionality
- Added a `--update` option to the `up` command in the CLI for forced updates during warm ACTIVE states. - Improved the idle-killer logic with new functions to check for reusable credentials and refresh settings on existing remote credentials. - Enhanced the `seed_civitai` function to implement caching for model jobs, optimizing the provisioning process. - Updated the installation script for Ollama to prevent unnecessary restarts when the service configuration has not changed. - Added diagnostics for model job caching and improved error handling in various functions.
This commit is contained in:
@@ -317,6 +317,19 @@ def main() -> int:
|
||||
return 1
|
||||
MARKER.parent.mkdir(parents=True, exist_ok=True)
|
||||
MARKER.write_text("ok\n", encoding="utf-8")
|
||||
# Dest list for warm seed short-circuit (local provision also writes fp).
|
||||
try:
|
||||
dests = []
|
||||
for job in json.loads(JOBS_PATH.read_text(encoding="utf-8")):
|
||||
if isinstance(job, dict) and job.get("dest"):
|
||||
dests.append(str(job["dest"]))
|
||||
if dests:
|
||||
Path("/mnt/swarm_data/.gpu-rent-models-jobs.json").write_text(
|
||||
json.dumps({"fp": "", "dests": dests}, indent=2) + "\n",
|
||||
encoding="utf-8",
|
||||
)
|
||||
except Exception:
|
||||
pass
|
||||
print("civitai seed ok")
|
||||
return 0
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ while IFS= read -r line || [[ -n "$line" ]]; do
|
||||
ENV_LINES+="Environment=${line}"$'\n'
|
||||
done < "$OLLAMA_ENV_FILE"
|
||||
|
||||
cat >/etc/systemd/system/${UNIT}.service <<EOF
|
||||
cat >/tmp/${UNIT}.service.new <<EOF
|
||||
[Unit]
|
||||
Description=gpu-rent Ollama (loopback, GPU-tuned)
|
||||
After=network-online.target local-fs.target
|
||||
@@ -164,6 +164,15 @@ RestartSec=5
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
UNIT_PATH=/etc/systemd/system/${UNIT}.service
|
||||
if [[ -f "$UNIT_PATH" ]] && cmp -s "/tmp/${UNIT}.service.new" "$UNIT_PATH" \
|
||||
&& systemctl is-active --quiet "$UNIT"; then
|
||||
rm -f "/tmp/${UNIT}.service.new"
|
||||
log "ok — unit без изменений и active, skip restart (OLLAMA_HOST=127.0.0.1:11434)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
mv "/tmp/${UNIT}.service.new" "$UNIT_PATH"
|
||||
systemctl daemon-reload
|
||||
systemctl enable "$UNIT"
|
||||
systemctl restart "$UNIT"
|
||||
|
||||
Reference in New Issue
Block a user