|
RADLib
RADical C++ application framework
|
RADService contains deployment-oriented helpers for running RADLib programs as long-lived services: systemd unit generation, watchdog/ready notifications, single-instance locks, and Unix daemonization. These helpers are useful for embedded appliances and desktop background tools that need reproducible service metadata.
A ServiceUnit describes a systemd service: its name, description, execStart command, optional workingDirectory, environment map, user, and wantedBy target. The restart policy is a RestartPolicy (No, OnFailure, or Always), and watchdogSec enables WatchdogSec when non-zero.
ServiceManager exposes the static helpers. generateSystemdUnit() serializes a ServiceUnit to unit-file text, and writeSystemdUnit() writes it into a target directory. restartPolicyName() converts a policy to its systemd token. For runtime supervision, notify() sends an sd_notify-compatible message to NOTIFY_SOCKET without linking libsystemd, with notifyReady() sending READY=1 and notifyWatchdog() sending WATCHDOG=1. daemonize() performs a Unix double-fork when supported.
SingleInstanceLock guards against concurrent instances using a RADCore::RADLockFile. Construct it with a lock path, call tryLock(), and check isLocked(); the lock is released in the destructor.
Core features:
ServiceUnit.RADCore::RADLockFile.Example: