Skip to contents

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, ...)

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.

Value

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

Examples

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