Asynchronous, highly-available services that share the lifecycle of your application.
(singleton-daemon daemon-name start-fn stop-fn)
Sets up a highly-available singleton daemon.
When a singleton daemon is started, a new thread is spawned, and
start-fn is invoked. When the application is shut down,
stop-fn is called.
In a WildFly cluster, daemons with the same
daemon-name can be created on each node, but only one of those daemons will run at a time. If the currently running daemon dies (or the node it is on loses connection with the cluster), the daemon will automatically start on one of the other nodes where it has been created.
If used outside of WildFly, or in a WildFly instance not in a cluster, it behaves as if the cluster size is 1, and starts immediatey.