Functional analyst during working hours 💼 and ... student 🎓 the remainder of the day. In my spare time I try to do some sporting activity 🏐. What's left over goes into REM sleep 🛌!
I'm no developer but I like playing around with
Last year I made a simple app called uCountVisualizer which I published in the shinyapps.io platform. Unfortunately the free tier offered only 25 hours a month for all the apps hosted in it. When I started to work on my second app uGeoTagger it became clear that this tier was insufficient. So was the next one which do not gave enoughs hours/month to host an app 24/7.
For that reason I googled a little bit and found Dean’s article which provided guidance to install the free version of shiny server. Dean is a shiny expert and by following his guide you’ll be able to:
As described in Dean’s article you may set a custom domain for your shiny server. However in my case, my domain (alessiobenedetti.com) was already used to host this blog in the github platform, therefore I needed to set up subdomains to bind the shiny server (thelab.alessiobenedetti.com).
sites-availableI created a file named
thelabwhere I specified the path through the index file and the subdomain, as shown in the image below
sites-enabledI created a symbolic link named
thelabthat references the
thelabfile in the
sites-availabledirectory. This can be done with the following statement
ln -s /etc/nginx/sites-available/thelab /etc/nginx/sites-enabled/thelab. For more details you can refer to the following guide on digital ocean and this post that I found useful to create symbolic links
/var/www. In the resulting path
/var/www/thelab/htmlyou can add your index.html
service nginx restartstatement, in order to make those changes effective
When I started developing the app I used a google sheet page as persistent storage. Despite R offers nice packages to manage google’s docs, I wasn’t satisfied of the loading time. That’s why I moved to a DB and chose Mongo. For simplicity I initially connected the app to an online istance of Mongo at the mlab.com hosting site. Later on, since the free tier of mlab.com doesn’t allow backups/restore, unless you pay for them, I decided to install my own istance of mongoDB. This guide was useful in doing that.
Browsing through mongoDB is made easier through a GUI browser. I found Robo 3T (formerly RoboMongo). Setting up the connection to the remote mongoDB was a little bit tricky because of the bad format of the private key. You need to create an Open SSH key (see this thread for support)
Last difficulty was automating the backup/restore jobs for the database. My wish was to create one daily backup, while keeping the last 5 backups day by day. I’ve had to dig on:
Point 1) came from the fact that “shell scripts are run inside a subshell, and each subshell has its own concept of what the current directory is.” (stack overflow reference). Initially I was working with aliases but then I wasn’t able to set the crontab job. At the end I simply created a function in a sh script that was easier to schedule on crontab.
End of this journey! I’ve made a quick recap of the main points, hope that you can eventually find some useful hints!