Refactor SSH commands to use nssm for managing the ollama service
This commit is contained in:
@@ -174,8 +174,9 @@ 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(2)
|
socket.sleep(2)
|
||||||
ssh('wsl.exe -d Debian -- sudo systemctl enable ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
ssh("nssm start ollama", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
ssh('wsl.exe -d Debian -- sudo systemctl start ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
--ssh('wsl.exe -d Debian -- sudo systemctl enable ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
|
--ssh('wsl.exe -d Debian -- sudo systemctl start ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
if (port_is_up(OLLAMA_HOST, OLLAMA_PORT, 90)) then
|
if (port_is_up(OLLAMA_HOST, OLLAMA_PORT, 90)) then
|
||||||
log("Ollama service is reachable again.")
|
log("Ollama service is reachable again.")
|
||||||
socket.sleep(30)
|
socket.sleep(30)
|
||||||
@@ -189,8 +190,9 @@ local function main()
|
|||||||
if line:find(FINISH_PATTERN, 1, true) ~= nil and powered_on == true then
|
if line:find(FINISH_PATTERN, 1, true) ~= nil and powered_on == true then
|
||||||
log(("Detected finish pattern: %q"):format(FINISH_PATTERN))
|
log(("Detected finish pattern: %q"):format(FINISH_PATTERN))
|
||||||
log("Shutting down Ollama host to save power...")
|
log("Shutting down Ollama host to save power...")
|
||||||
ssh('wsl.exe -d Debian -- sudo systemctl disable ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
ssh("nssm stop ollama", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
ssh('wsl.exe -d Debian -- sudo systemctl stop ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
--ssh('wsl.exe -d Debian -- sudo systemctl disable ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
|
--ssh('wsl.exe -d Debian -- 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)
|
ssh("shutdown.exe /s /t 0", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
socket.sleep(5)
|
socket.sleep(5)
|
||||||
powered_on = false
|
powered_on = false
|
||||||
|
|||||||
Reference in New Issue
Block a user