From 9c92018454df4f230da2d7c9c965c0a663c8dbaf Mon Sep 17 00:00:00 2001 From: Isaac True Date: Tue, 22 Sep 2026 19:49:11 +0200 Subject: [PATCH 1/4] snap: add server app Add a disabled-by-default service which runs the llama-cpp server. --- snap/snapcraft.yaml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index cc3cc74..23edde8 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -88,10 +88,10 @@ components: apps: llama-cpp: command: bin/cli-wrapper - extensions: + extensions: &extensions # Automatically binds host Vulkan/OpenGL maps - gpu - plugs: + plugs: &plugs - home - network - network-bind @@ -106,6 +106,12 @@ apps: # llama.cpp pins worker threads with sched_setaffinity. Without this # application fails to init. - process-control + server: + command: bin/cli-wrapper server + daemon: simple + install-mode: disable + extensions: *extensions + plugs: *plugs parts: # --- Wrapper script ------------------------------------------------------ cli: From 3f447369378470ef5bd744b831157fed5320cda8 Mon Sep 17 00:00:00 2001 From: Isaac True Date: Tue, 22 Sep 2026 19:50:16 +0200 Subject: [PATCH 2/4] snap: move cli.sh to subdirectory Moving to a subdirectory improves change detection reliability. --- cli.sh => scripts/cli.sh | 0 snap/snapcraft.yaml | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename cli.sh => scripts/cli.sh (100%) diff --git a/cli.sh b/scripts/cli.sh similarity index 100% rename from cli.sh rename to scripts/cli.sh diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 23edde8..5894327 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -116,7 +116,7 @@ parts: # --- Wrapper script ------------------------------------------------------ cli: plugin: dump - source: . + source: scripts stage: - bin/cli-wrapper organize: From 019563358fc8688c2688bcb694141c6d918d6d20 Mon Sep 17 00:00:00 2001 From: Isaac True Date: Tue, 22 Sep 2026 20:06:28 +0200 Subject: [PATCH 3/4] snap: allow configuring server command line arguments --- scripts/server.sh | 7 +++++++ snap/hooks/configure | 5 +++++ snap/snapcraft.yaml | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) create mode 100755 scripts/server.sh diff --git a/scripts/server.sh b/scripts/server.sh new file mode 100755 index 0000000..a763fa4 --- /dev/null +++ b/scripts/server.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Add additional command line arguments as configured +SERVER_OPTS=() +read -r -a SERVER_OPTS <<< "$(snapctl get server-opts)"; +exec "${SNAP}"/bin/cli-wrapper server "${SERVER_OPTS[@]}" diff --git a/snap/hooks/configure b/snap/hooks/configure index 409523a..4fe3c4c 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -19,3 +19,8 @@ esac if [ -z "$backend" ]; then snapctl set backend=auto fi + +# Set the default value for server-opts +if [ -z "$(snapctl get server-opts)" ]; then + snapctl set server-opts="" +fi diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index 5894327..f3b1aef 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -107,7 +107,7 @@ apps: # application fails to init. - process-control server: - command: bin/cli-wrapper server + command: bin/server-wrapper daemon: simple install-mode: disable extensions: *extensions @@ -119,8 +119,10 @@ parts: source: scripts stage: - bin/cli-wrapper + - bin/server-wrapper organize: cli.sh: bin/cli-wrapper + server.sh: bin/server-wrapper # --- ggml: CPU + loader libs, lives in the main snap -------------------- # Builds llama.cpp's bundled ggml/ subdirectory standalone with the # backend-dl loader enabled and every CPU variant emitted as its own .so. From 9d11e2c39a12c1184fffab89b8ede3ea6c85ac6e Mon Sep 17 00:00:00 2001 From: Isaac True Date: Wed, 23 Sep 2026 15:54:22 +0200 Subject: [PATCH 4/4] snap: update description with server information --- snap/snapcraft.yaml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/snap/snapcraft.yaml b/snap/snapcraft.yaml index f3b1aef..004bcea 100644 --- a/snap/snapcraft.yaml +++ b/snap/snapcraft.yaml @@ -21,6 +21,21 @@ description: | or override it per invocation with the env var: LLAMA_CPP_BACKEND=cpu llama-cpp cli ... + + The llama.cpp web server can also be run using the llama-cpp.server app. This + is disabled by default but can be enabled by running: + + snap start --enable llama-cpp.server + + By default, no additional arguments are passed to the server, meaning it will + listen on the default port and address. Arguments can be specified by setting + the server-opts configuration value, e.g.: + + snap set llama-cpp server-opts="--host 0.0.0.0" + + Afterwards, the server must be restarted for the new arguments to take effect: + + snap restart llama-cpp.server license: MIT source-code: - https://github.com/talhaHavadar/snap-llama.cpp