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
)
location of TGVE path to be served by plumber.
to serve from.
host to pass to plumber default `http://127.0.0.1` to `FALSE`.
run the R process in the background using `callr`, defaults to `TRUE`.
whether to start the server, defaults to `TRUE`. If not, then the created server will be returned.
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`.
{
# 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