def start
      @java_daemon.set_action do
        action
      end

      @java_daemon.set_error_callback do |_, err|
        on_error(err)
      end

      @java_daemon.set_stop_callback do |_|
        on_stop
      end

      @java_daemon.start

      self
    end
def start
      @java_daemon.set_action do
        action
      end

      @java_daemon.set_error_callback do |_, err|
        on_error(err)
      end

      @java_daemon.set_stop_callback do |_|
        on_stop
      end

      @java_daemon.start

      self
    end
Creates a daemon object.

 Optionally takes a block that is the action of the daemon. If
 not provided, you must extend this class and override {#action}
 if you want the daemon to actually do anything. The block will
 be passed the daemon object.

 @param name [String] The name of this daemon. Needs to be the
   same across a cluster for :singleton to work, and must be
   unique.
 @param options [Hash] Options for the daemon.
 @option options :singleton [true, false] (true)
 @option options :on_error [Proc] A custom error handler, will be
   passed the daemon object and the error (see {#on_error})
 @option options :on_stop [Proc] A custom stop handler, will be
   passed the daemon object (see {#on_stop})
 @option options :stop_timeout [Number] (30_000) Milliseconds to
   wait for the daemon thread to exit when stopping.
 Starts the daemon. If :singleton and in a cluster, the daemon
 may not be running on the current node after calling start.
 @return [Daemon] self