From dde2623ad37cd7e0c09d2dc507a19336c3f24a95 Mon Sep 17 00:00:00 2001 From: Jeff Ohrstrom Date: Fri, 26 Jul 2024 14:44:10 -0400 Subject: [PATCH] allow for variable websockify timeout (#840) --- lib/ood_core/batch_connect/templates/vnc.rb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/ood_core/batch_connect/templates/vnc.rb b/lib/ood_core/batch_connect/templates/vnc.rb index 48b438581..92befa1de 100644 --- a/lib/ood_core/batch_connect/templates/vnc.rb +++ b/lib/ood_core/batch_connect/templates/vnc.rb @@ -134,7 +134,8 @@ def run_script def after_script websockify_cmd = context.fetch(:websockify_cmd, "${WEBSOCKIFY_CMD:-/opt/websockify/run}").to_s websockify_hb = context.fetch(:websockify_heartbeat_seconds, "${WEBSOCKIFY_HEARTBEAT_SECONDS:-30}").to_s - + websockify_timeout_seconds = context.fetch(:websockify_timeout_seconds, '${WEBSOCKIFY_TIMEOUT_SECONDS:-10}').to_s + <<-EOT.gsub(/^ {14}/, "") #{super} @@ -146,6 +147,7 @@ def after_script #{websockify_cmd} $1 --heartbeat=#{websockify_hb} $2 &> $log_file & local ws_pid=$! local counter=0 + local max_timeout=#{websockify_timeout_seconds} # wait till websockify has successfully started echo "[websockify]: pid: $ws_pid (proxying $1 ==> $2)" >&2 @@ -156,9 +158,9 @@ def after_script if ! ps $ws_pid > /dev/null; then echo "[websockify]: failed to launch!" >&2 return 1 - elif [ $counter -ge 10 ]; then - # timeout after ~10 seconds - echo "[websockify]: timed-out :(!" >&2 + elif [ $counter -ge $max_timeout ]; then + # timeout after max_timeout seconds + echo "[websockify]: timed-out after $max_timeout seconds :(!" >&2 return 1 else sleep 1