-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.R
80 lines (61 loc) · 2.89 KB
/
server.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# Source all reactive ui elements, observers, reactive()
# manually instantiate reactiveValues here
server <- function(input, output, session) {
# Check for minio if minio version or MAP is enabled
if (Minio_Test | MAP | Compose_Test) {
# Load map data access
library(mapDataAccess)
# Connect to a local minio run
source("./MAP_Functions.R", local = TRUE)
# Create a reactive values to hold MAP specific objects
if (Minio_Test) {
MapConnect <- reactiveValues(MapConnect = map_data_connection(config_file = "./cfg/minio_config_local.yml"), Data = NULL)
map_con <- map_data_connection(config_file = "./cfg/minio_config_local.yml")
} else if (Compose_Test) {
MapConnect <- reactiveValues(MapConnect = map_data_connection(config_file = "./cfg/minio_config_compose.yml"), Data = NULL, Trelliscope = NULL, Job = NULL)
map_con <- map_data_connection(config_file = "./cfg/minio_config_compose.yml")
} else if (MAP) {
MapConnect <- reactiveValues(MapConnect = map_data_connection(config_file = "minio_config.yml"), Data = NULL, Trelliscope = NULL, Job = NULL)
map_con <- map_data_connection(config_file = "minio_config.yml")
}
if (Minio_Test | Compose_Test | MAP) {
# Pull all IDs
IDs <- get_all_data_ids(map_con)
if ("Jobs" %in% IDs == FALSE) {
jobs <- read.table("./Jobs.txt", header = T)
put_data(map_con, jobs, id = "Jobs")
set_tags(map_con, "Jobs", list("ObjectType" = "job-tracker", "ProjectName" = "jobs file", "DataType" = "job tracker"))
}
}
} else {
hide(id = "loading-gray-overlay")
}
# Add the redis container
if (MAP | Redis_Test | Compose_Test) {
if (Redis_Test) {
redis_url <- "redis://redis1:6379/0"
} else if (MAP | Compose_Test) {
# Register url, this is running in another docker container alongside this one
if(!file.exists("./cfg/redis_config.yml")){
warning("No redis configuration found, attempting connection to default url: redis://redis1:6379")
redis_url <- "redis://redis1:6379/0"
} else {
redis_cfg = yaml::read_yaml("redis_config.yml")
redis_host = redis_cfg[['host']]
redis_url <- sprintf('redis://%s:%s/%s',
redis_host,
redis_cfg[['port']],
redis_cfg[['db']])
}
}
message("Setting up redis connection at: ", redis_url)
# Import celery package from the virtual environment
clry <- reticulate::import('celery')
celery_app = clry$Celery('app', broker=redis_url, backend=redis_url)
}
# source all 'modules'
for(folder in c('reactive_variables', 'preprocessing', 'reactive_ui',
'plot_functions', 'observers')){
for(f in Sys.glob(sprintf('./%s/*.R', folder))) source(f, local=TRUE)
}
}