headless: register signal handlers synchronously, split tests, drop deployment examples and wording
This commit was merged in pull request #2.
This commit is contained in:
@@ -1,33 +0,0 @@
|
||||
# NixOS module: runs a Sausage world as a service (see README, "As a service").
|
||||
# Create the world once: sudo -u sausage nix run git+https://gitea.surma.technology/surma/sausage -- init /var/lib/sausage/world
|
||||
{ config, lib, pkgs, ... }:
|
||||
let cfg = config.services.sausage; in
|
||||
{
|
||||
options.services.sausage = {
|
||||
enable = lib.mkEnableOption "the Sausage world";
|
||||
world = lib.mkOption { type = lib.types.str; default = "/var/lib/sausage/world"; };
|
||||
flake = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "git+https://gitea.surma.technology/surma/sausage";
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
users.users.sausage = { isSystemUser = true; group = "sausage"; home = "/var/lib/sausage"; createHome = true; };
|
||||
users.groups.sausage = { };
|
||||
systemd.services.sausage = {
|
||||
description = "Sausage world";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
after = [ "network-online.target" ];
|
||||
wants = [ "network-online.target" ];
|
||||
path = [ pkgs.nix pkgs.git ];
|
||||
serviceConfig = {
|
||||
User = "sausage";
|
||||
WorkingDirectory = "/var/lib/sausage";
|
||||
ExecStart = "${pkgs.nix}/bin/nix run ${cfg.flake}#loop -- --headless ${cfg.world}";
|
||||
Restart = "on-failure";
|
||||
RestartSec = 5;
|
||||
TimeoutStopSec = 30;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
# Sausage as a systemd service. Create the world once as the service user:
|
||||
# nix run git+https://gitea.surma.technology/surma/sausage -- init /var/lib/sausage/world
|
||||
# Then: install as /etc/systemd/system/sausage.service, `systemctl enable --now sausage`.
|
||||
# Adjust User and the path to `nix`.
|
||||
[Unit]
|
||||
Description=Sausage world
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
|
||||
[Service]
|
||||
User=sausage
|
||||
WorkingDirectory=/var/lib/sausage
|
||||
# The loop restarts the host (newest version) after a crash or a broker `exit`.
|
||||
# --headless: no console, stdin EOF does not stop the world.
|
||||
ExecStart=/run/current-system/sw/bin/nix run git+https://gitea.surma.technology/surma/sausage#loop -- --headless /var/lib/sausage/world
|
||||
Restart=on-failure
|
||||
RestartSec=5
|
||||
# SIGTERM stops the host cleanly (exit code 0).
|
||||
KillMode=control-group
|
||||
TimeoutStopSec=30
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
Reference in New Issue
Block a user