tests/testthat/pub_runif.R

#!/usr/bin/env Rscript
library(methods)
f <- function(filename) {
  if (!file.exists(filename)) {
    message("No file - exiting")
    return()
  }
  dat <- readLines(filename)
  ch <- dat[[1]]
  dt <- as.numeric(dat[[2]])
  con <- redux::hiredis()
  message(Sys.getpid())
  flush(stderr())
  while (file.exists(filename)) {
    con$PUBLISH(ch, runif(1))
    Sys.sleep(dt)
  }
}
f(commandArgs(TRUE)[[1]])

Try the redux package in your browser

Any scripts or data that you put into this service are public.

redux documentation built on May 2, 2019, 1:42 p.m.