The function accepts a `path` to get a directory containing an instance of TGVE, by default this is done via `TEMP_DIR_ENV` env variable. If neither is given then the function copies a clean copy of the bundled TGVE version into a temporary directory.

tgve_server(
  path = Sys.getenv("TEMP_path_ENV"),
  port = 8000,
  host = "127.0.0.1",
  background = FALSE,
  run = TRUE
)

Arguments

path

location of TGVE path to be served by plumber.

port

to serve from.

host

host to pass to plumber default `http://127.0.0.1` to `FALSE`.

background

run the R process in the background using `callr`, defaults to `TRUE`.

run

whether to start the server, defaults to `TRUE`. If not, then the created server will be returned.

Value

the valude returned depends on: (1) `run`, if it is FALSE then an instance of `plumber::pr`, (2) if `run` is true and `background` is TRUE the `plumber::pr` instance is started and its process is returned, and (3) if `run` is TRUE and `background` is FALSE then a message is displayed showing the blocking `plumber::pr` instance's `path`, `port` and `host`.

Examples

{
# This will run in the background using `callr`
ps = tgve_server(background = TRUE)
Sys.sleep(2)
ps$kill()
}
#> Attempting to serve TGVE instance from: /tmp/Rtmp1i03Cg/tgve
#> Running plumber at: http://127.0.0.1/8000
#> [1] TRUE