# FreeToken engine supervisor — reference systemd unit (WSL user service or native Linux). # # Install (user service, works under WSL which supports systemd): # mkdir -p ~/.config/systemd/user # cp ft-daemon.service ~/.config/systemd/user/ # # edit ExecStart to point at your checkout's venv, then: # systemctl --user daemon-reload # systemctl --user enable --now ft-daemon # systemctl --user status ft-daemon # # The engine (`ft serve`) is a CHILD of this daemon but MUST outlive it: closing/restarting the # control plane must not unload ~22 GB of weights. Two settings make that true: # * KillMode=process — on stop/restart systemd signals ONLY the daemon's main process, not the # whole control group, so the serve keeps running and the next daemon re-adopts it from the # pidfile. (With the default KillMode=control-group, systemd would SIGKILL the serve on every # restart and re-adoption could never fire.) # * The daemon detaches from the serve on SIGTERM by default (it does not stop it); pass # --stop-serve-on-exit only if the engine should die together with the daemon. [Unit] Description=FreeToken engine supervisor (ft daemon) After=network.target [Service] Type=simple # Point this at your checkout's venv-installed entrypoint: ExecStart=%h/FreeToken/.venv/bin/ft daemon --host 127.0.0.1 --port 1900 Restart=always RestartSec=1 # Do not give up restarting after N fast failures — the control plane must always come back. StartLimitIntervalSec=0 # Only signal the main process on stop/restart, so the serve child survives for re-adoption. KillMode=process KillSignal=SIGTERM # Best-effort: bias the OOM killer away from the tiny daemon. Note this is typically INEFFECTIVE # for an unprivileged --user service (lowering oom_score_adj needs CAP_SYS_RESOURCE); the daemon # instead makes the serve the preferred victim by raising the serve tree's score at runtime. OOMScoreAdjust=-1000 [Install] WantedBy=default.target