Skip to content

Commit

Permalink
lockfile_status_tracker
Browse files Browse the repository at this point in the history
  • Loading branch information
m7pr committed Jul 10, 2024
1 parent a7f0666 commit 3c480a7
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 14 deletions.
3 changes: 1 addition & 2 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ init <- function(data,
if (!is.null(landing_module)) {
do.call(landing_module$server, c(list(id = "landing_module_shiny_id"), landing_module$server_args))
}
session$userData$lockfile_process <- process
reactivePoll(1000, session, checkFunc = lockfile_status, valueFunc = function() {})
lockfile_status_tracker(process)
srv_teal_with_splash(id = id, data = data, modules = modules, filter = deep_copy_filter(filter))
}
)
Expand Down
29 changes: 17 additions & 12 deletions R/teal_lockfile.R
Original file line number Diff line number Diff line change
Expand Up @@ -96,18 +96,23 @@ teal_lockfile_downloadhandler <- function() {
)
}

lockfile_status <- function() {
process <- session$userData$lockfile_process
if (!process$is_alive()) {
renv_logs <- process$read_output()

if (any(grepl("Lockfile written", renv_logs))) {
logger::log_trace("lockfile created successfully.")
} else {
logger::log_trace("lockfile created with issues.")
}
TRUE
lockfile_status <- function(process) {
renv_logs <- process$read_output()
if (any(grepl("Lockfile written", renv_logs))) {
logger::log_trace("lockfile created successfully.")
} else {
FALSE
logger::log_trace("lockfile created with issues.")
}
}

lockfile_status_tracker <- function(process) {
timer <- reactiveTimer(1000)

tracker <- observe({
timer()
if (!process$is_alive()) {
lockfile_status(process)
tracker$destroy()
}
})
}

0 comments on commit 3c480a7

Please sign in to comment.