ollama
ollama copied to clipboard
Ollama should clear temp files on exit.
Found that upon exiting, Ollama does not delete temporary files, but upon starting, Ollama creates new identical files again. in temp folder ''..AppData\Local\Temp"
OS: Windows 11
@amnweb thank you so much for this. We definitely do try to clean up the tmp files on exit. This is definitely a bug. Sorry!
Hi folks,
I've been trying to look into why this happens, and it turns out that when we use exec.CommandContext: https://github.com/ollama/ollama/blob/2a4b128ae3e3a18b10e8701aca2434d401eaa7ba/app/lifecycle/server_windows.go#L10 and call the cancel() method, it seems to internally send a SIGKILL
Source code
It also looks like we can set a custom Cancel function to be called when the context is canceled, per this part of the code
Does it make sense to update the Cancel hook to send a SIGTERM to the serve command, wait for a pre-defined timeout and then send a kill signal if the process does not exit? ( I think we can check this by inspecting Cmd.ProcessState
cc: @mchiang0610