If you run a long running calculation on a remote machine your calculation can fail if the machine falls over, the network goes down, or your code crashes R. This package provides a “heartbeat” service that uses Redis to periodically prevent a key from expiring, forming a dead man’s switch. You can then monitor the key to detect failure in your process and re-queue/rerun/investigate as appropriate.
f <- function() {
h <- heartbeatr::heartbeat("mykey", 4)
# ... long running job here
# h$stop() # optional - will stop automatically once h is garbage collected
}
drat:::add("mrc-ide")
install.packges("heartbeatr")
It is also possible to install directly from GitHub using remotes
as
remotes::install_github("mrc-ide/heartbeatr", ugprade = FALSE)