Learn R Programming

doconv (version 0.4.0)

run_in_shiny_app: Run a command against a running Shiny application

Description

Starts a Shiny app in a background process, waits for it to be ready, executes an arbitrary command via processx::run(), and stops the app on exit.

Usage

run_in_shiny_app(app_expr, port = 9999, timeout = 120, ...)

Value

The value returned by processx::run() (a list with status, stdout, stderr, timeout).

Arguments

app_expr

A character string containing an R expression to launch the Shiny app, executed via Rscript -e. The expression must start the app on the specified port (e.g. "shiny::runApp('app/', port = 9999)").

port

HTTP port used by the Shiny app. Default is 9999.

timeout

Maximum number of seconds to wait for the app to be ready. Default is 120.

...

Arguments passed to processx::run(). At minimum, command must be provided.

Examples

Run this code
if (FALSE) {
res <- run_in_shiny_app(
  app_expr = "shiny::runApp('app/', port = 9999)",
  command = "npm", args = c("run", "scenario", "import-flow"),
  wd = tempdir()
)
}

Run the code above in your browser using DataLab