Skip to content

Commit

Permalink
fix socket auth msg+checking
Browse files Browse the repository at this point in the history
  • Loading branch information
mschubert committed Feb 22, 2019
1 parent 552f68d commit 11be0f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions R/qsys.r
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,13 @@ QSys = R6::R6Class("QSys",
fill_options = function(...) {
values = utils::modifyList(private$defaults, list(...))
values$master = private$master
values$auth = private$auth = paste(sample(letters, 5, TRUE), collapse="")
if ("auth" %in% names(infuser::variables_requested(private$template))) {
values$auth = private$auth = paste(sample(letters, 5, TRUE), collapse="")
} else {
values$auth = NULL
warning("Add 'CMQ_AUTH={{ auth }}' to template to enable socket authentication",
immediate.=TRUE)
}
if (!"job_name" %in% names(values))
values$job_name = paste0("cmq", private$port)
private$workers_total = values$n_jobs
Expand All @@ -226,11 +232,6 @@ QSys = R6::R6Class("QSys",
fill_template = function(values) {
# note: auth will be obligatory in the future and this check will
# be removed (i.e., filling will fail if no field in template)
if (! "auth" %in% names(infuser::variables_requested(private$template))) {
values$auth = NULL
warning("Add 'CMQ_AUTH={{ auth }}' to template to enable socket authentication",
immediate.=TRUE)
}
infuser::infuse(private$template, values)
},

Expand Down
3 changes: 2 additions & 1 deletion R/worker.r
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ worker = function(master, timeout=600, ..., verbose=TRUE) {
id = "WORKER_DONE",
time = run_time,
mem = sum(gc()[,6]),
calls = counter
calls = counter,
auth = auth
))

message("\nTotal: ", sprintf(fmt, counter, run_time[1], run_time[2], run_time[3]))
Expand Down

0 comments on commit 11be0f2

Please sign in to comment.