Starts up an execution daemon to receive mirai() requests. Awaits data,
evaluates an expression in an environment containing the supplied data,
and returns the value to the host caller. Daemon settings may be controlled
by daemons() and this function should not need to be invoked directly,
unless deploying manually on remote resources.
daemon(
url,
dispatcher = TRUE,
...,
asyncdial = FALSE,
autoexit = TRUE,
cleanup = TRUE,
output = FALSE,
idletime = Inf,
walltime = Inf,
maxtasks = Inf,
tlscert = NULL,
rs = NULL
)Invisibly, an integer exit code: 0L for normal termination, and a positive value if a self-imposed limit was reached: 1L (idletime), 2L (walltime), 3L (maxtasks).
(character) host or dispatcher URL to dial into, e.g. 'tcp://hostname:5555' or 'tls+tcp://10.75.32.70:5555'.
(logical) whether dialing into dispatcher or directly to host.
reserved for future use.
(logical) whether to dial asynchronously. FALSE errors if
connection fails immediately. TRUE retries indefinitely (more resilient
but can mask connection issues).
(logical) whether to exit when the socket connection ends.
TRUE exits immediately, NA completes current task first, FALSE
persists indefinitely. See Persistence section.
(logical) whether to restore global environment, packages, and options to initial state after each evaluation.
(logical) whether to output stdout/stderr. For local daemons
via daemons() or launch_local(), redirects output to host process.
(integer) milliseconds to wait idle before exiting.
(integer) milliseconds of real time before exiting (soft limit).
(integer) maximum tasks to execute before exiting.
(character) for secure TLS connections. Either a file path to
PEM-encoded certificate authority certificate chain (starting with the TLS
certificate and ending with the CA certificate), or a length-2 vector of
(certificate chain, empty string "").
(integer vector) initial .Random.seed value. Set automatically by
host process; do not supply manually.
The autoexit argument governs persistence settings for the daemon. The
default TRUE ensures that it exits as soon as its socket connection with
the host process drops. A 200ms grace period allows the daemon process to
exit normally, after which it will be forcefully terminated.
Supplying NA ensures that a daemon always exits cleanly after its socket
connection with the host drops. This means that it can temporarily outlive
this connection, but only to complete any task that is currently in progress.
This can be useful if the daemon is performing a side effect such as writing
files to disk, with the result not being required back in the host process.
Setting to FALSE allows the daemon to persist indefinitely even when there
is no longer a socket connection. This allows a host session to end and a new
session to connect at the URL where the daemon is dialed in. Daemons must be
terminated with daemons(NULL) in this case instead of daemons(0). This
sends explicit exit signals to all connected daemons.
Daemons dial into the host or dispatcher, which listens at url. This
allows network resources to be added or removed dynamically, with the host
or dispatcher automatically distributing tasks to all connected daemons.