Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ramalama serve cannot be ctrl-c #618

Open
vpavlin opened this issue Jan 22, 2025 · 14 comments
Open

Ramalama serve cannot be ctrl-c #618

vpavlin opened this issue Jan 22, 2025 · 14 comments

Comments

@vpavlin
Copy link

vpavlin commented Jan 22, 2025

ramalama serve without -d will attach to the TTY, but will not react to CTRL+C

@ericcurtin
Copy link
Collaborator

Seems like it's this issue:

containers/podman#14707

@ericcurtin
Copy link
Collaborator

Doesn't occur without containers

@vpavlin
Copy link
Author

vpavlin commented Jan 22, 2025

I am not using podman (at the moment):)

(.venv) root@pi5:/home/vpavlin/ramalama# docker version
Client:
 Version:           20.10.24+dfsg1
 API version:       1.41
 Go version:        go1.19.8
 Git commit:        297e128
 Built:             Sat Oct 12 15:19:49 2024
 OS/Arch:           linux/arm64
 Context:           default
 Experimental:      true

Server:
 Engine:
  Version:          20.10.24+dfsg1
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.19.8
  Git commit:       5d6db84
  Built:            Sat Oct 12 15:19:49 2024
  OS/Arch:          linux/arm64
  Experimental:     false
 containerd:
  Version:          1.6.20~ds1
  GitCommit:        1.6.20~ds1-1+b1
 runc:
  Version:          1.1.5+ds1
  GitCommit:        1.1.5+ds1-1+deb12u1
 docker-init:
  Version:          0.19.0
  GitCommit:        

@ericcurtin
Copy link
Collaborator

ericcurtin commented Jan 22, 2025

podman or docker (I said containers, just referenced the podman issue as an example), doesn't happen with no containers

@rhatdan
Copy link
Member

rhatdan commented Jan 23, 2025

What does ramalama info show?

@rhatdan
Copy link
Member

rhatdan commented Jan 23, 2025

Looks like you are running in a docker container, which should forward the SIGTERM to the PID 1 of the container, llama-server. If this is not exiting, then I would guess llama-serve is ignoring SIGTERM.

@rhatdan
Copy link
Member

rhatdan commented Jan 23, 2025

Doing some testing it looks like llama-serve is ignoreing SIGINT and SIGTERM

@ericcurtin
Copy link
Collaborator

It's supposed to call this in llama.cpp

inline void signal_handler(int signal) {
    if (is_terminating.test_and_set()) {
        // in case it hangs, we can force terminate the server by hitting Ctrl+C twice
        // this is for better developer experience, we can remove when the server is stable enough
        fprintf(stderr, "Received second interrupt, terminating immediately.\n");
        exit(1);
    }

    shutdown_handler(signal);
}

@ericcurtin
Copy link
Collaborator

ericcurtin commented Jan 23, 2025

@rhatdan tested sending signals to llama-server with no containers with:

kill 2 PID

and

kill 15 PID

manually. Seemed to work fine.

@ericcurtin
Copy link
Collaborator

I can confirm it's reproducible with podman on macOS, could be a podman remote thing though.

@rhatdan
Copy link
Member

rhatdan commented Jan 25, 2025

I reproduced locally and entered the container and the llama-run would not exit with kill TERM or kill INT. Do not know what the difference is.

@vpavlin
Copy link
Author

vpavlin commented Jan 27, 2025

What does ramalama info show?

Well, not much:D

# ramalama --debug info
run_cmd:  docker info --format json
Working directory: None
Ignore stderr: False
Ignore all: False
Command finished with return code: 0
Error: Expecting value: line 1 column 1 (char 0)

@ericcurtin
Copy link
Collaborator

ericcurtin commented Jan 27, 2025

It looks like it's both an issue for podman and docker. Probably the best way to fix is in llama.cpp upstream, we should log this there.

@rhatdan
Copy link
Member

rhatdan commented Jan 27, 2025

The interesting thing is what could cause it to work correctly outside of a container but blow up inside of a container. this means it must be examining something about it's environment and blocking the receiving of these signals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants