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).
the character host or dispatcher URL to dial into, including the port to connect to, e.g. 'tcp://hostname:5555' or 'tls+tcp://10.75.32.70:5555'.
logical value, which should be set to TRUE if using dispatcher and FALSE otherwise.
reserved, but not currently used.
whether to perform dials asynchronously. The default FALSE
will error if a connection is not immediately possible (for instance if
daemons()
has yet to be called on the host, or the specified port is not
open etc.). Specifying TRUE continues retrying (indefinitely) if not
immediately successful, which is more resilient but can mask potential
connection issues.
logical value, whether the daemon should exit automatically
when its socket connection ends. By default, the process ends immediately
when the host process ends. Supply NA
to have a daemon complete any tasks
in progress before exiting (see 'Persistence' section below).
logical value, whether to perform cleanup of the global environment and restore attached packages and options to an initial state after each evaluation.
logical value, to output generated stdout / stderr if TRUE, or
else discard if FALSE. Specify as TRUE in the ...
argument to daemons()
or launch_local()
to provide redirection of output to the host process
(applicable only for local daemons).
integer milliseconds maximum time to wait for a task (idle time) before exiting.
integer milliseconds soft walltime (time limit) i.e. the minimum amount of real time elapsed before exiting.
integer maximum number of tasks to execute (task limit) before exiting.
required for secure TLS connections over 'tls+tcp://'.
Either the character path to a file containing X.509 certificate(s) in
PEM format, comprising the certificate authority certificate chain starting
with the TLS certificate and ending with the CA certificate, or a
length 2 character vector comprising (i) the certificate authority
certificate chain and (ii) the empty string ""
.
the initial value of .Random.seed. This is set automatically using L'Ecuyer-CMRG RNG streams generated by the host process if applicable, and should not be independently supplied.
The autoexit
argument governs persistence settings for the daemon. The
default TRUE ensures that it will exit as soon as its socket connection
with the host process drops.
Supplying NA
will allow a daemon to exit cleanly once its socket connection
with the host process drops, as soon as it has finished any task that is
currently in progress. This may be useful if the daemon is performing some
side effect such as writing files to disk, and the result is not required 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 dialled in. Daemons must be
terminated with daemons(NULL)
in this case instead of daemons(0)
. This
sends explicit exit signals to all connected daemons.
The network topology is such that daemons dial into the host or dispatcher,
which listens at the url
address. In this way, network resources may be
added or removed dynamically and the host or dispatcher automatically
distributes tasks to all available daemons.