{"id":16391637,"url":"https://github.com/jcrodriguez1989/shinyparallel","last_synced_at":"2025-03-21T02:32:10.877Z","repository":{"id":44470589,"uuid":"148354680","full_name":"jcrodriguez1989/shinyParallel","owner":"jcrodriguez1989","description":"Package: Run Shiny applications in a multi-session mode","archived":false,"fork":false,"pushed_at":"2021-06-23T12:50:11.000Z","size":33,"stargazers_count":59,"open_issues_count":2,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-12T04:46:51.814Z","etag":null,"topics":["multiuser","parallel","shiny","shiny-server"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jcrodriguez1989.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-11T17:32:22.000Z","updated_at":"2024-10-02T20:27:32.000Z","dependencies_parsed_at":"2022-09-23T06:23:18.600Z","dependency_job_id":null,"html_url":"https://github.com/jcrodriguez1989/shinyParallel","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2FshinyParallel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2FshinyParallel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2FshinyParallel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jcrodriguez1989%2FshinyParallel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jcrodriguez1989","download_url":"https://codeload.github.com/jcrodriguez1989/shinyParallel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221811384,"owners_count":16884305,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["multiuser","parallel","shiny","shiny-server"],"created_at":"2024-10-11T04:46:53.522Z","updated_at":"2024-10-28T09:10:29.910Z","avatar_url":"https://github.com/jcrodriguez1989.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\ntitle: \"ShinyParallel\"\noutput: github_document\n---\n\nRun [Shiny](http://shiny.rstudio.com/) applications in a multi-session mode.\n\nPrevents that if a user executes a long computing task penalizing\nothers.\n\nShinyParallel manages incoming users and redistributes them between multiple \nsessions created for your Shiny app. It provides two modes of use:\n\n* From an R console: ShinyParallel reimplements the function \n`shiny::runApp(\u003cparams\u003e)`. In this sense, the only thing to do to run an app \nin multi-session mode is to call it using `shinyParallel::runApp(\u003cparams\u003e)`.\n* Installing ShinyParallel in a Shiny server (**may require root**): by the \n`shinyParallel::installShinyParallel(\u003cparams\u003e)` function, ShinyParallel is \ninstalled in your Shiny server for any desired app.\n\n**Note:** ShinyParallel should work on any operating system that supports R,\nhowever it has been tested only under Linux (Ubuntu).\n\n## Features\n\n* Run a Shiny app in multiple sessions (processes / physical cores).\n* Decide the maximum number of users per session.\n* It allows to visualize the number of users currently present in each session.\n\n## Installation\n\nShinyParallel is currently only available as a GitHub package. To install it run\nthe following from an R console:\n\n```{r eval=FALSE}\nif (!require(\"remotes\")) {\n  install.packages(\"remotes\")\n}\nremotes::install_github(\"jcrodriguez1989/shinyParallel\")\n```\n\n## runApp mode\n\n### Usage\n\nIf you run your Shiny app like this:\n\n```{r eval=FALSE}\nrunApp(appDir=myApp, \u003cotherParams\u003e)\n```\n\nJust replace it by:\n\n```{r eval=FALSE}\nshinyParallel::runApp(appDir=myApp, \u003cotherParams\u003e)\n```\n\nThe only parameter that varies is `port`, in `shinyParallel::runApp` the\nparameter is modified by `ports`. And instead of being `numeric` of length 1, it\nwill now be numeric of length equal to the number of ports available to use.\nWhere the first port will be used by the ShinyParallel app, and the rest by the\ngenerated sessions.\n\nThe `shinyParallel::runApp` function has two additional parameters:\n\n* `max.sessions`: Maximum number of sessions to use.\n* `users.per.session`: Maximum number of admited users per each session.\n\n### Example\n\n```{r eval=FALSE}\nlibrary(\"shiny\")\n\n# Create a Shiny app object\napp \u003c- shinyApp(\n  ui = fluidPage(\n    column(3, wellPanel(\n      numericInput(\"n\", label = \"Is it prime?\", value = 7, min = 1),\n      actionButton(\"check\", \"Check!\")\n    ))\n  ),\n  server = function(input, output) {\n    # Check if n is prime.\n    # Not R optimized.\n    # No Fermat, Miller-Rabin, Solovay-Strassen, Frobenius, etc tests.\n    # Check if n is divisable up to n-1 !!\n    isPrime \u003c- function(n) {\n      res \u003c- TRUE\n      i \u003c- 2\n      while (i \u003c n) {\n        res \u003c- res \u0026\u0026 n %% i != 0\n        i \u003c- i + 1\n      }\n      return(res)\n    }\n    observeEvent(input$check, {\n      showModal(modalDialog(\n        ifelse(isPrime(isolate(input$n)),\n          \"Yes it is!\", \"Nope, not a prime.\"\n        ),\n        footer = NULL,\n        easyClose = TRUE\n      ))\n    })\n  }\n)\n\n# Run it with Shiny\nshiny::runApp(app)\n# Run it with ShinyParallel default params\nshinyParallel::runApp(app)\n# Run it with ShinyParallel, give one session per user\nshinyParallel::runApp(app, max.sessions = Inf, users.per.session = 1)\n```\n\nIn this example, if the app is run with `shiny::runApp`, and a user wants to\ncalculate if the number 179424691 is prime then the app will be blocked for\nother users for some minutes, if the app is run with `shinyParallel::runApp` \nnot.\n\nIf the shiny app url is `http://\u003curl\u003e:\u003cport\u003e/` then enter\n`http://\u003curl\u003e:\u003cport\u003e/?admin` to view a panel that lists the number of users\ncurrently present in each session.\n\n## installShinyParallel mode\n\n### Usage\n\nIf your application is at `\u003cmyAppPath\u003e`, i.e., from an R terminal \n`runApp(\u003cmyAppPath\u003e)` starts the app, then to install it on the server just run \nR as root (or make sure the actual user has write permissions on the Shiny \nserver) and run the `installShinyParallel(\u003cmyAppPath\u003e)` command.\n\n### Example\n\nFirst, let's create our Shiny app, from a Linux terminal type:\n```{bash eval=F}\ncd ~\nmkdir myShinyApp\necho \"\n    library('shiny')\n    \n    # Create a Shiny app object\n    app \u003c- shinyApp(\n      ui = fluidPage(\n        column(3, wellPanel(\n          numericInput('n', label = 'Is it prime?', value = 7, min = 1),\n          actionButton('check', 'Check!')\n        )\n      )),\n      server = function(input, output) {\n        # Check if n is prime.\n        # Not R optimized.\n        # No Fermat, Miller-Rabin, Solovay-Strassen, Frobenius, etc tests.\n        # Check if n is divisable up to n-1 !!\n        isPrime \u003c- function(n) {\n          res \u003c- TRUE\n          i \u003c- 2\n          while (i \u003c n) {\n            res \u003c- res \u0026\u0026 n %% i != 0\n            i \u003c- i + 1\n          }\n          return(res)\n        }\n        observeEvent(input\\$check, {\n          showModal(modalDialog(\n            ifelse(isPrime(isolate(input\\$n)),\n                'Yes it is!', 'Nope, not a prime.'),\n            footer = NULL,\n            easyClose = TRUE\n          ))\n        })\n      }\n    )\n\" \u003e myShinyApp/app.R\n```\n\nSo now we can try our app, and install it with multi-session feature, from a R \n(sudo) console type:\n\n```{r eval=F}\nlibrary(\"shinyParallel\")\n# And install it\nshinyParallel::installShinyParallel(\"./myShinyApp\",\n  max.sessions = 20,\n  users.per.session = 5\n)\n```\n\n\n## Limitations\n\n* Each session that ShinyParallel generates is independent of the others, i.e.,\nthe global variables of a session (shiny app) will not be modified in another\none. Two users present in different session will not be able to interact with\nthe same values of the variables.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcrodriguez1989%2Fshinyparallel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjcrodriguez1989%2Fshinyparallel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjcrodriguez1989%2Fshinyparallel/lists"}