Shiny server on EC2: URL lists folder content instead of displaying app - r

[Sorry, newbie here!]
I've just installed R server, shiny server on an ubuntu EC2 instance. I have left the shiny-server.conf intact, except that I added: preserve_logs true;. The sample app was working fine.
I have removed /srv/shiny-server/index.html and /srv/shiny-server/sample-apps.
I have linked my app files from my /home/myapp directory to /srv/shiny-server/myapp. The app files consists of a single apps.R, a footer.html, and a small dataset .Rds, and a www/style.css file.
When I navigate to http://[myip]:3838/ the only thing is the directory listing; the only folder is : myapp. When I click to http://[myip]:3838/myapp/ , I see the directory listing as well. That is, I see the content, and I can download each of them. BUt I see no evidence of the app running. If I click on apps.R, my browser downloads the file.
PS: the app works fine when tested in Rstudio, or deployed on Shinyapps.io

If anyone from the future reads this, I wish you heard the loud headslap when I realized my app single-file should be called app.R, not apps.R (which makes a lot of sense in retrospect).

Related

Unsure where image_write downloads to in shinyapps.io

I'm attempting to make a public shinyapps.io website, and I'm trying to use image_write to create a file into a local directory.
The following code works on my local R studio code:
image_write(im.resized, path = paste0(output_file_directory, file_name), format = "jpg")
When I run the code on the shinyapps.io website, the code runs without error, but I'm not sure where it downloads the file to. I know that the output_file_directory part isn't the issue, so I'm a little lost. Any help would be much appreciated!
On shinyapps.io it is not possibly to store permanently data, due to:
"Shinyapps.io is a popular server for hosting Shiny apps. It is designed to distribute your Shiny app across different servers, which means that if a file is saved during one session on some server, then loading the app again later will probably direct you to a different server where the previously saved file doesn’t exist."
See here:
https://shiny.rstudio.com/articles/persistent-data-storage.html

packrat not bundling all files

I have developed several shiny applications on a development server. To aid with deployment to our production server I've written a function that uses packrat's bundle function to bundle up the application. My function then sftps the bundle to the production server and then sends a command over ssh to call packrat::unbundle() on the production server.
When I first wrote this it all seemed to work but a few months, maybe a year, ago it started messing up. It would report that the app was restored on production but the app wouldn't open on the production server. When I would look at the directory for the app it would not include all the files associated with the application. When I open the bundle on the development server it does not contain all the files that should be there. What would cause packrat::bundle() to not include all the files in the bundled directory? For example, the bundle contains the packrat folder, the .Rproj file, one of two associated .csv data files, and a restart.txt file, but does not contain ui.R, server.R, global.R, or one .csv file. It isn't always consistently wrong, every great once in a while it works fine... I am very confused... any help or insight would be appreciated.
Thanks

ShinyApps on AWS with Rstudio AMI

I created an AWS instance with this R Studio AMI.
The instructions point that to make the Shiny App available to public you should put it in a ShinyApps folder (public dir).
The issue I'm having though, is that my apps are accesable only through that particular directory, but I can't access them through subdirectories.
For instance:
http://<instance IP address>/shiny/username - works
http://<instance IP address>/shiny/**subdirectory**/username - doesnt work
So I can't really show more than one Shiny App on a single instance.
My goal is to create an index.html page that links several ShinyApps like this one.
Update:
I've updated my index.html with this repo
The problem is again, when I link an app from the index.html I get only the R code opens up, rather than the app.

Converted UWP... Nothing Happens

I have converted a Win32 Application to UWP using MakeAppX and it doesn't seem to run. When I click the icon in the start menu literally nothing happens except a busy icon briefly appears on the cursor.
I completed the same process with Notepad++ and all it's DLLs and that worked fine (using the exact same manifest file, just changing the exe)
My questions are:
Where does the UWP save files that it creates/temporary files etc? If I run an executable and it generates files next to it, where would that be when you run a UWP?
Can I set that location in the AppxManifest?
Is there anyway to see if it has run correctly or not?
Edit:
Could this be a file permissions issue? My application needs to write to 'C:\MyFolder' & creates a folder with a load of files next to the executable upon startup and that doesn't happen.
So looking into this a bit more I came across this blog which discusses preparing for conversion. I think the above file accesses probably contravene the following:
Your app writes to the install directory for your app. For example, your app writes to a log file that you put in the same directory as your exe. This isn't supported, so you'll need to find another location, like the local app data store.
This looks like a fairly halting issue, am I correct in that assumption?
If your app is writing to the install directory you will need to change that code to write to your local app data folder instead, as the preparation guide calls out.
Write operations to the install directory are not allowed in order to ensure the ability for the app deployment stack to perform seamless, differential updates and clean uninstalls of your app.
Btw, to debug through your app launch failures you can do the following in Visual Studio: Debug -> Other Debug Target -> Debug Installed App Package -> select your app from the list of installed apps.

Shiny putting app into production

I have created my first Shiny app and i want to share it with people.
I have a folder which contains my ui.R file and my Server.R file.
I have managed to get a server for it and install Shiny Server and it runs pretty well. In fact I have written the shiny app in the web browser.
My question is where do I save the scripts on the shiny server so that I can send the link to people and it will just load up as a website (assuming they have credentials?
Thank you for your time.
I found another question similiar to the one i was looking for.
Hosting LAN Shiny apps run from command line
This answers the question by specifiying that i should move my test scripts into production by saving them /srv/shiny-server/myApp
Which server do you use? Perhaps AWS (Amazon)? Then you can upload it in one of the folders on your server. In the case of Amazon, you do it through S3 Browser.
You can use a domain name to redirect you to the specific folder where you keep your shiny apps. Each shiny app should have its own sub-directory where you keep server and ui scripts. Then you load your shiny name like this:
yourdomain.com/sub_directory_where_shiny_script_are_located
Don't forget to adjust your directories in the script, so that when you load any data, it loads the data located on ubuntu server, for example.
if(Sys.info()[['user']] %in% c("ubuntu","shiny") ) {
load("/a2cka/ShinyApps/sub_directory_shin_app_/data.csv}

Resources