Closed mvaldes14 closed 3 months ago
So if I understand your issue correctly, plenary is running the start
job under a different user, causing permissions issues?
basically yes - the ollama process is launched as the "ollama" user which is weird since the binary itself is owned by root.
➜ ll `which ollama`
.rwxr-xr-x 288M root 15 Feb 17:14 /usr/local/bin/ollama
➜ stat /usr/local/bin/ollama
File: /usr/local/bin/ollama
Size: 287837496 Blocks: 562192 IO Block: 4096 regular file
Device: 8,3 Inode: 9568257 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
But when the pkill command is sent, it cannot be stopped/killed since the user running neovim has no permissions over that process so the server keeps running in the background forever.
The plugin reports that the server is stopped since the exit code is 1 - Server is already stopped
but in reality it is still running.
https://github.com/nomnivore/ollama.nvim/blob/main/lua/ollama/init.lua#L424
➜ pkill -SIGTERM ollama
pkill: killing pid 193844 failed: Operation not permitted
✗ echo $?
1
➜ ps -ef | grep ollama
ollama 193844 1 5 17:14 ? 00:00:13 /usr/local/bin/ollama serve
Did some further research and seems like the serve process is launched by the systemd unit so i guess that explains why it runs under another user.
For linux then we could maybe omit the nvim command since it won't work and will report false information.
I think it differs from system to system. On my end the serve process gets started by the user, so it can be stopped in the same way. The API connection works regardless.
My recommendation for now is to start/stop the ollama service separately from the plugin-provided commands if you have permissions/user issues.
First of all thanks for the plugin, works great!. Added my prompts in a minute and they work as intended.
Now i have the problem that the server doesn't really stop as it's being launched with another user so the pkill -SIGTERM ollama won't work as it cannot destroy the process.
If I manually run
OllamaServeStop
it says the server is no longer running. But doing a check on my process list i can see this.notice the user running the program.
If i try to stop it.
In theory plenary should have started the job with the same user that initiated neovim, so I'm a little confused.