Skip to main content

Managing Shiny App(s)

UpdatingThese are instructions on how to manage standard shiny apps. For password protection please see New Password Protected Shiny App Deployment (Internal Only)

We assume you have a basic understanding of linux filesystem commands such as sudo, cp, ls, rm -r, mkdir. If you need help please reach out

File Structure

All shiny app is quite simple. You just overwrite a file and reload the server.

Filesapps are stored in /srv/shiny-server. This directory corosponds to the root of your website (ie https://shiny.phs.ucdavis.edu/)

Procedure

Any subdirectories you create will be paths in your url. For instance:

Inside these folders you must have file(s) with one of these nameing schemes in order to successfully load a webpage.

  • index.html (you can link to css, js, and other files like with other web servers)
  • index.Rmd
  • server.R and ui.R (Shiny App)
  • ui.R (Shiny App)

If you want to use something else for a homepage (ie. php) please contact IT and we can get that set up for you.

Adding Shiny Apps/Websites

  1. Get your filefiles onto the server.
    This is usually done with SFTP
  2. FigureMake outsure wherethe itdirectory is supposed to go.
    A single server can have multiple shiny apps. You will need to look in /srv/shiny-server to see where it goes. Ifpath you need morefor informationthat app exists. If it doesn't you can alsocreate checkit outwith thesomething apache/nginxlike: configs
    sudo tomkdir see-P which/srv/shiny-server/myapp1
    folder
    might hold the shiny app you are updating.
  3. Copy andyour overwritefiles to the oldpath shinyyou appneed (
    sudo cp ~/ui.R /srv/shiny-server/myapp1/
    )
  4. Make sure the permissions and ownership of all the shiny-server files are correct.
    ShinyYou Appscan mustjust havecopy, onepaste, ofand run the following filenames:as is:
    app.sudo chmod -R 755 /srv/shiny-server
    sudo chown -R shiny:shiny /srv/shiny-server
    ,
    both server.R and ui.R, or index.Rmd depending on what type of app they have written. You may need to rename the file.
  5. Reload your shiny server to apply changes
    sudo systemctl reloadrestart shiny-server
    

ThatYou shouldare now done. Go verify your site is up at the path you expect it to be.

If your app gives you an error please see the Basic Troubleshooting section below

Updating Shiny Apps

The process of updating a shiny app is more or less the same as above.

  1. Get your files onto the server. This is usually done with SFTP
  2. Replace your app with the new code
    sudo cp ~/ui.R /srv/shiny-server/myapp1/ui.R
    
  3. Make sure the permissions and ownership of all the shiny-server files are correct.
    You can just copy, paste, and run the following as is:
    sudo chmod -R 755 /srv/shiny-server
    sudo chown -R shiny:shiny /srv/shiny-server
    
  4. Reload your shiny server to apply changes
    sudo systemctl restart shiny-server
    

If your app gives you an error please see the Basic Troubleshooting section below

Removing Shiny Apps

To remove a shiny app just delete the app and reload

  1. Delete the app
    sudo rm -r /srv/shiny-server/myapp1
    
  2. Reload your shiny server to apply changes
    sudo systemctl restart shiny-server
    

Basic Troubleshooting

If your app gives you an error and you are following the instructions above, it is likely because a package your app is using is not installed and you did not use an R package manager like pacman. In that case just install any packages by running R with:

sudo R

And installing your packages as normal. You might need to do this with any packages loaded with the library() function

> install.packages(c("shiny", "gdata", "ggmap", "ggplot2"))

You may also want to update all packages to ensure things keep working smoothly. This can be it.done in R with the following although this can take a while (30+ minutes):

update.packages(ask = FALSE, checkBuilt = TRUE)