From e0572388d15641d02454380ab53e6f512e09eb14 Mon Sep 17 00:00:00 2001 From: IlyaZar Date: Sat, 24 Feb 2024 18:11:25 +0100 Subject: [PATCH] fix: try again maintenance --- deploy.R | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/deploy.R b/deploy.R index 5579fdc..dabafbb 100644 --- a/deploy.R +++ b/deploy.R @@ -19,7 +19,29 @@ set_env_deploy <- function() { Sys.setenv("APP_NAME" = Sys.getenv(env_var_name)) } # -Sys.setenv("GOLEM_MAINTENANCE_ACTIVE" = TRUE) +set_golem_maintenance <- function(MAINTENANCE = FALSE) { + stopifnot(`Value for arg. 'MAINTENANCE' must be logical` = + is.logical(MAINTENANCE)) + write_renviron_maintenance(MAINTENANCE) +} +write_renviron_maintenance <- function(VAL, fn_name = ".Renviron") { + STATE_TO_WRITE <- paste0("GOLEM_MAINTENANCE_ACTIVE=", VAL) + if (file.exists(fn_name)) { + tmp_file <- readLines(fn_name) + check_SET_GMA <- grepl("GOLEM_MAINTENANCE_ACTIVE", tmp_file) + if (any(check_SET_GMA)) { + tmp_file[check_SET_GMA] <- STATE_TO_WRITE + } else { + tmp_file <- c(tmp_file, STATE_TO_WRITE) + } + writeLines(tmp_file, fn_name) + } else { + writeLines(STATE_TO_WRITE, fn_name) + } + return(invisible(NULL)) +} +# +set_golem_maintenance(TRUE) # Authenticate rsconnect::setAccountInfo( name = error_on_missing_name("SHINY_ACC_NAME"),