Available

amalgame-service

SIGTERM / SIGINT + Windows SCM dispatcher.

amc package add service GitHub ↗ ← Back to the ecosystem

Overview

Cross-OS daemon/service integration. Linux/macOS: clean SIGTERM and SIGINT handling for graceful shutdown. Windows: the binary is a real service (native SCM dispatcher), registered with sc.exe, no NSSM or third-party wrapper.

Features

  • ✓Cross-OS SIGTERM / SIGINT handlers
  • ✓Native Windows Service Control Manager (since v0.2)
  • ✓amc new --template service scaffolds the systemd unit and the launchd plist
  • ✓The same template ships the install.sh, install-macos.sh and install.ps1 install scripts
  • ✓Service.Sleep(ms) returns as soon as shutdown starts; Service.RequestStop() stops from inside the program

Example

Minimal usage example — copy-paste runnable after install.

amc package add service

import Amalgame.Service

class Program {
    public static int Main(List<string> args) {
        Service.RunAsService("my-app")   // SIGTERM / SIGINT; on Windows, the SCM too
        while (!Service.ShouldStop()) {
            Console.WriteLine("working")
            Service.Sleep(5000)          // returns early on shutdown
        }
        Console.WriteLine("clean shutdown")
        return 0
    }
}

At a glance

Related packages