Running Models YourselfLesson 60 of 82

Module 7 · Serving it to other people

Running it as a service that survives a reboot

In this lesson

  • 8 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 5 of 9 in this chapter

This chapter’s goalExpose a local model as a service other people can use safely (bound to loopback and reached over SSH or a WireGuard mesh, fronted by a gateway that holds keys and quotas, packaged and supervised so it restarts on its own, logging what is needed without retaining prompts you cannot defend) and state what an unauthenticated inference port costs you within hours of being reachable.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 9Free · no account needed
Lesson steps

The gap between working and running

A model started in a terminal stops when the terminal closes, when the SSH session drops, when the machine reboots after a kernel update, and when the process runs out of memory. A service supervisor closes all four gaps. On Linux that is systemd, which is already installed; on macOS it is launchd; on a Windows machine the practical answer is to run the engine inside WSL2 and supervise it there.

A minimal unit for a llama.cpp server:

INI
# /etc/systemd/system/llama.service
[Unit]
Description=llama.cpp server
After=network-online.target

[Service]
User=llama
Group=llama
ExecStart=/opt/llama.cpp/llama-server \
  -m /srv/models/qwen2.5-7b-instruct-q4_k_m.gguf \
  --host 127.0.0.1 --port 8080 -c 8192 -ngl 99
Restart=always
RestartSec=5
TimeoutStartSec=600

[Install]
WantedBy=multi-user.target
Bash
sudo systemctl daemon-reload && sudo systemctl enable --now llama
journalctl -u llama -f      # the logs, with no extra software

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Every lesson here is open. Your progress is recorded once you pass the Open Model Ecosystem exam.

Stuck on something?Ask Tri, your AI tutor

How to cite: Addaly (2026) ‘Running it as a service that survives a reboot’, in Running Models Yourself. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/running-models-yourself/running-it-as-a-service (Accessed: 27 November 2026).