Last active
January 23, 2025 19:13
-
-
Save bryanpaget/38f77f7b74c2eff9ed423fa5e375484d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Function to test if a package can be loaded | |
| test_package_load <- function(package_name) { | |
| if (!requireNamespace(package_name, quietly = TRUE)) { | |
| message(sprintf("Package '%s' is not installed. Skipping.", package_name)) | |
| return(FALSE) | |
| } | |
| message(sprintf("Testing package: %s", package_name)) | |
| # Attempt to load the package | |
| tryCatch({ | |
| library(package_name, character.only = TRUE) | |
| message(sprintf("Package '%s' loaded successfully.", package_name)) | |
| return(TRUE) | |
| }, error = function(e) { | |
| message(sprintf("Failed to load package '%s': %s", package_name, e$message)) | |
| return(FALSE) | |
| }) | |
| } | |
| # Get the list of all installed packages | |
| packages_to_test <- installed.packages()[, "Package"] | |
| # Run load tests for all installed packages | |
| results <- sapply(packages_to_test, test_package_load) | |
| # Summary of results | |
| message("\nTesting completed.") | |
| message("Summary:") | |
| summary_results <- sapply(seq_along(packages_to_test), function(i) { | |
| pkg <- packages_to_test[i] | |
| result <- ifelse(results[i], "Success", "Failed") | |
| sprintf("%s: %s", pkg, result) | |
| }) | |
| message(paste(summary_results, collapse = "\n")) | |
| # Exit with non-zero code if any test fails | |
| if (!all(results)) { | |
| stop("One or more packages failed to load. Check the logs for details.", call. = FALSE) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| RSTUDIO_URL="http://localhost:8787" | |
| curl -f -s "$RSTUDIO_URL" || { echo "RStudio not responding"; exit 1; } | |
| echo "RStudio is running correctly." |
Author
We can also run
(base) jovyan@bryan-paget-notebook-0:~/workspace$ ps aux | grep rstudio-server
jovyan 2599 0.1 0.1 4950052 240672 ? Sl 16:23 0:18 /usr/lib/rstudio-server/bin/rsession -u jovyan --session-use-secure-cookies 1 --session-root-path /notebook/bryan-paget/bryan-paget-notebook/rstudio/ --session-same-site 2 --session-use-file-storage 1 --launcher-token E235A62C --r-restore-workspace 2 --r-run-rprofile 2
jovyan 4906 0.0 0.0 9168 2320 pts/1 S+ 19:09 0:00 grep --color=auto rstudio-server
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.