Skip to content

Commit ac046c3

Browse files
committed
only add cron job if not exists
updated README
1 parent 6d5b331 commit ac046c3

3 files changed

Lines changed: 26 additions & 7 deletions

File tree

experiment-trait-data-visualizer/README.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,24 @@
1414
- leaflet
1515
- cronR
1616

17-
#### Data cached in 'cache.RData'
18-
#### BETYdb remote access uses ssh tunnel: ssh -Nf -L 5432:localhost:5432 bety6.ncsa.illinois.edu
19-
#### [Request access](https://identity.ncsa.illinois.edu/join/TU49BUUEDM)
20-
#### Set the following environment variables
17+
```{r echo=FALSE}
18+
lapply(list('shiny', 'shinythemes', 'lubridate', 'dplyr', 'ggplot2', 'timevis', 'rgeos', 'leaflet', 'cronR'),
19+
install.packages)
20+
```
21+
22+
to install cron (Ubuntu)
23+
24+
```sh
25+
apt-get update
26+
apt-get install cron
27+
```
28+
29+
#### Setup and Notes
30+
31+
* Data are cached in a file `cache.RData` and updated using the cronR R interface to cron
32+
* Access to BETYdb remote access requires ssh tunnel `ssh -Nf -L 5432:localhost:5432 bety6.ncsa.illinois.edu`
33+
* requires access, which can be [requested here](https://identity.ncsa.illinois.edu/join/TU49BUUEDM)
34+
* Set the following environment variables
2135

2236
- bety_dbname ('bety')
2337
- bety_password

experiment-trait-data-visualizer/app.R

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ source('render-site-map.R')
1010

1111
# schedule daily execution of cache refresh
1212
cache_update_cmd <- cron_rscript('cache-refresh.R')
13-
try(cron_add(command = cache_update_cmd, frequency = 'daily',
14-
id = 'cache-update', description = 'daily update of BETYdb cache'))
13+
14+
if(!grepl('cache-update', cronR::cron_ls())){
15+
cron_add(command = cache_update_cmd, frequency = 'daily',
16+
id = 'cache-update', description = 'daily update of BETYdb cache')
17+
}
18+
1519

1620
# set page UI
1721
ui <- fluidPage(theme = shinytheme('flatly'),

experiment-trait-data-visualizer/cache-refresh.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,9 @@ get_data_for_season <- function(season) {
101101

102102
# load existing full_cache_data object if exists, otherwise use empty list object
103103
full_cache_data <- list()
104-
if (file.exists("cache.RData"))
104+
if (file.exists("cache.RData")){
105105
load("cache.RData")
106+
}
106107

107108
# save data for given season
108109
full_cache_data[[ toString(season[[ 'name' ]]) ]] <- season_data

0 commit comments

Comments
 (0)