feat: allow passing of global settings launching from R or running docker container.

This commit is contained in:
Andreas Gammelgaard Damsbo 2026-03-11 13:22:54 +01:00
commit 8935b0b2a4
No known key found for this signature in database
5 changed files with 29 additions and 28 deletions

View file

@ -23,11 +23,11 @@ launch_FreesearchR <- function(inlcude_globalenv = TRUE,
data_limit_upper = 100000,
data_limit_lower = 1,
...) {
global_freesearchR <- list(
include_globalenv = include_globalenv,
data_limit_default = data_limit_default,
data_limit_upper = data_limit_upper,
data_limit_lower = data_limit_lower
Sys.setenv(
INCLUDE_GLOBALENV = include_globalenv,
DATA_LIMIT_DEFAULT = data_limit_default,
DATA_LIMIT_UPPER = data_limit_upper,
DATA_LIMIT_LOWER = data_limit_lower
)
appDir <- system.file("apps", "FreesearchR", package = "FreesearchR")
@ -39,3 +39,21 @@ launch_FreesearchR <- function(inlcude_globalenv = TRUE,
a <- shiny::runApp(appDir = paste0(appDir, "/app.R"), ...)
return(invisible(a))
}
## Helper to set env variables
get_config <- function(var_name, default = NULL) {
# First check environment variables (set by Docker)
val <- Sys.getenv(var_name, unset = NA)
if (!is.na(val) && nzchar(val)) {
return(val)
}
# Fall back to default (can be overridden when launching from R)
if (!is.null(default)) {
return(default)
}
stop(paste("Required config variable not set:", var_name))
}