marinebon / sdg14

Products for Sustainable Development Goal 14 on Life in the Sea
http://marinebon.github.io/sdg14
3 stars 0 forks source link

shiny-server returning "Not Found" on apps #24

Closed bbest closed 6 years ago

bbest commented 6 years ago

When visiting a Shiny app, eg http://mbon.marine.usf.edu:3838/test/, I'm now getting Not Found error:

image

Was working until 4am PST this morning, but had to change a bunch of permissions on rstudio-shiny server so may be related.

bbest commented 6 years ago

Hi @7yl4r,

Everything was working pretty well up until 4am PST, and then at 10:30am PST I see this error, which is a total show stopper. I'm pretty sure is related to https://github.com/marinebon/sdg14/issues/25. I'm having a hell of a time sorting through this and could use an extra set of eyes. Would you have time tomorrow to look at this with me?

Thanks, Ben

bbest commented 6 years ago

Confused b/c according to mbon host, shiny should be hosting shiny apps located in /srv/shiny-server, per /etc/shiny-server/shiny-server.conf on rstudio-shiny docker instance per ...

docker logs rstudio-shiny
[2017-08-01 20:21:32.908] [INFO] shiny-server - Shiny Server v1.5.4.847 (Node.js v6.10.3)
[2017-08-01 20:21:32.913] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2017-08-01 20:21:32.966] [WARN] shiny-server - Running as root unnecessarily is a security risk! You could be running more securely as non-root.
[2017-08-01 20:21:32.970] [INFO] shiny-server - Starting listener on 0.0.0.0:3838

Then to inspect /etc/shiny-server/shiny-server.conf on rstudio-shiny, login into terminal ...

docker exec -it rstudio-shiny bash

So in instance...

view /etc/shiny-server/shiny-server.conf

Here's the contents of /etc/shiny-server/shiny-server.conf:

# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;

# Define a server that listens on port 3838
server {
  listen 3838;

  # Define a location at the base URL
  location / {

    # Host the directory of Shiny Apps stored in this directory
    site_dir /srv/shiny-server;

    # Log all Shiny output to files in this directory
    log_dir /var/log/shiny-server;

    # When a user visits the base URL rather than a particular application,
    # an index of the applications available in this directory will be shown.
    directory_index on;
  }
}

But weirdly docker logs rstudio-shiny reported:

Running as root unnecessarily is a security risk! You could be running more securely as non-root.

This, despite the /etc/shiny-server/shiny-server.conf having the run_as shiny; argument.

bbest commented 6 years ago

Ah hah! Thanks so much Tylar for awesome help with this. Turns out the extra Rmd in the shiny root folder was giving it issues, so this fixed it:

cd /mbon/shiny
mv seascape_prep.Rmd ../.
mv mbon_postgis_db.R ../.

This was found by visiting http://mbon.marine.usf.edu:8787/ which gave a different error about checking your logs and then noticing on host mbon:

cd /mbon/shiny-log/
ls -latr /mbon/shiny-log
cat env-shiny-20170801-204237-41950.log
processing file: seascape_prep.Rmd
Quitting from lines 48-61 (seascape_prep.Rmd) 
Warning: Error in raster: could not find function "raster"
Stack trace (innermost first):
    115: eval
    114: eval
    113: withVisible
    112: withCallingHandlers
    111: handle
    110: timing_fn
    109: evaluate_call
    108: evaluate::evaluate
    107: evaluate
    106: in_dir
    105: block_exec
    104: call_block
    103: process_group.block
    102: process_group
    101: withCallingHandlers
    100: process_file
     99: knitr::knit
     98: <Anonymous>
     97: do.call
     96: contextFunc
     95: .getReactiveEnvironment()$runWith
     94: shiny::maskReactiveContext
     93: <reactive>
     82: doc
     81: shiny::renderUI
     80: func
     79: origRenderFunc
     78: output$__reactivedoc__
      3: <Anonymous>
      2: do.call
      1: rmarkdown::run