Skip to contents

Given a bit of R code, runs it in the background, checks if the R process is still alive, and if the R process has died, launches it again. Requires packages sys and ps.

Usage

ft_r_launch_watch_relaunch(
  command,
  args = NULL,
  ntry = 10,
  check_interval = 60,
  status_expected = c("sleeping", "running"),
  ...
)

Arguments

command

the R code to run as a string

args

the command arguments

ntry

how many times to try relaunching the command

check_interval

how long to wait in seconds before checking on it

status_expected

what status is expected, default is "sleeping" & "running"

...

other arguments passed to sys::exec_background

Value

NULL invisibly

Details

Note: this writes the command provided to an R file in tmp, and then passes it via std_in.