Shiny App

From UFRC
Revision as of 14:49, 2 August 2021 by Magitz (talk | contribs) (Updating content)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

To use a 'shiny' R app on the HiPerGator and access it via your web browser you can follow these steps:

App Development

Start Shiny

The example is using the 01_hello histogram Demo from the Shiny demo gallery.

  • Log into the HiPerGator
  • Start an interactive job: e.g. srun --mem=4gb --time=08:00:00 --pty bash -i
  • Load the R module and launch R, get the IP address of the machine your job is on:
$ module load R
$ R
> system('hostname -i')
172.16.201.61 # Example output; your IP will likely be different!
> library(shiny)
> runExample("01_hello", host="172.16.201.61") 


One you run the above for a demo or from within your Shiny App directory for a real app you will see the

Listening on http://172.xxx.yyy.zzz:pppp

message that shows you the IP address and the port to connect to. That completes the HiPerGator part. Please note that we will not be connecting to that IP address and the port directly. See below.

Your output may look like:
Listening on http://172.16.201.61:5856
/usr/bin/xdg-open: 869: www-browser: not found
/usr/bin/xdg-open: 869: links2: not found
/usr/bin/xdg-open: 869: elinks: not found
/usr/bin/xdg-open: 869: links: not found
/usr/bin/xdg-open: 869: lynx: not found
/usr/bin/xdg-open: 869: w3m: not found
xdg-open: no method available for opening 'http://172.16.201.61:5856'
Do not worry, shiny should still work.

Connect to the Shiny App

On the 'local' side i.e. the desktop or the laptop you are on create an SSH tunnel to your shiny app:

For a MacOSX or Linux system it's as simple as running the following command:

ssh -L local_port:shiny_IP:shiny_port myuser@hpg.rc.ufl.edu

E.g.

ssh -L 5856:172.xxx.yyy.zzz:5856 jdoe@hpg.rc.ufl.edu

Once the tunnel is created go to your web browser and connect to http://localhost:5856. You should see the Shiny App interface in the browser.