Browse Source

Enhance ollama service management: increase delay before starting service, add shutdown logic after service reachability check

main
Bastian (BaM) 3 months ago
parent
commit
006b7c716e
  1. 11
      scripts/auto-boot-ollama-host.lua

11
scripts/auto-boot-ollama-host.lua

@ -174,8 +174,17 @@ local function main()
if port_is_up(OLLAMA_HOST, SSH_PORT, 60) then if port_is_up(OLLAMA_HOST, SSH_PORT, 60) then
log("SSH is reachable. Starting ollama service...") log("SSH is reachable. Starting ollama service...")
socket.sleep(1) socket.sleep(2)
ssh("wsl.exe -d Debian -- 'sudo systemctl enable --now ollama && sudo systemctl start ollama'", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE) ssh("wsl.exe -d Debian -- 'sudo systemctl enable --now ollama && sudo systemctl start ollama'", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
if (port_is_up(OLLAMA_HOST, OLLAMA_PORT, 90)) then
log("Ollama service is reachable again.")
socket.sleep(120)
log("Shutting down Ollama host to save power...")
ssh("wsl.exe -d Debian -- 'sudo systemctl disable ollama && sudo systemctl stop ollama'", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
ssh("shutdown.exe /s /t 0", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
else
log("Timeout waiting for Ollama service to come up after SSH command.")
end
end end
end end
end end

Loading…
Cancel
Save