alias daemon = Daemon!( "DaemonizeExample1", KeyValueList!( Signal.Terminate, (logger) { logger.logInfo("Exiting..."); return false; // returning false will terminate daemon }, Signal.HangUp, (logger) { logger.logInfo("Hello World!"); return true; // continue execution } ), (logger, shouldExit) { // will stop the daemon in 5 minutes auto time = Clock.currSystemTick + cast(TickDuration)5.dur!"minutes"; bool timeout = false; while(!shouldExit() && time > Clock.currSystemTick) { } logger.logInfo("Exiting main function!"); return 0; } );
Template for describing daemon in the package.
To describe new daemon you should set unique name and signal -> callbacks mapping.
name is used to name default pid and lock files of the daemon and also it is a service name in Windows.
pSignalMap is a KeyValueList template where keys are Signal values and values are delegates of type:
If the delegate returns false, daemon terminates.