Closed max-zilla closed 5 years ago
might be easier to just use cron job in kubernetes - trigger one of these "jobs" periodically
can remove lines ~ 12-23 in app.R https://github.com/terraref/traitvis-webapp/pull/18/files#diff-1e678274602e250345bb25d52e7c2d76R12 that set up cron from within R. Can also probably remove cron dependencies in R and OS
Need some logic to know when to refresh the data from disk. Also should write to a a tempfile in same folder then move to final landing spot to prevent your app from loading half a file.
The cron job doesn't currently refresh RData cache properly in traitviz app, and in discussions with @robkooper we determined that having such a cron job is contrary to docker's "single thread" model per container.
Suggested solution:
modify mounts on traitviz .yaml in kubernetes so the cache.RData file is written to our storage, perhaps in ua-mac/www directory? this means it doesn't have to be rebuilt on startup each time.
add an entrypoint.sh script for the Dockerfile in the app with 2 possible commands: 1 to run the app as normal, the other to refresh the cache (and nothing else). The first will be normal container we run to serve up the app, the second will be a "job" (https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/) that we configure to periodically run to completion. we will need a separate yaml to define the job, i think.
set up cron job on kubernetes master node itself to run the refresh job every day at 1am or something.