From b6736fc570cce78d0b47a7b0c2c91fd8e0686d13 Mon Sep 17 00:00:00 2001 From: Duncan Mortimer Date: Thu, 29 Feb 2024 15:15:19 +0000 Subject: [PATCH] Add configurable websocket heartbeat Without the --heartbeat option the VNC session will timeout after 1 minute of idle time. This adds --heartbeat with a default of 30 seconds, configurable with websockify_hb in the context or the environment variable WEBSOCKIFY_HB --- lib/ood_core/batch_connect/templates/vnc.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/ood_core/batch_connect/templates/vnc.rb b/lib/ood_core/batch_connect/templates/vnc.rb index e45ca8d60..6d271fb3f 100644 --- a/lib/ood_core/batch_connect/templates/vnc.rb +++ b/lib/ood_core/batch_connect/templates/vnc.rb @@ -130,7 +130,8 @@ def run_script # successful connections so that the password can be reset def after_script websockify_cmd = context.fetch(:websockify_cmd, "${WEBSOCKIFY_CMD:-/opt/websockify/run}").to_s - + websockify_hb = context.fetch(:websockify_hb, "${WEBSOCKIFY_HB:-30}").to_s + <<-EOT.gsub(/^ {14}/, "") #{super} @@ -139,7 +140,7 @@ def after_script start_websockify() { local log_file="./websockify.log" # launch websockify in background and redirect all output to a file. - #{websockify_cmd} $1 $2 &> $log_file & + #{websockify_cmd} $1 --heartbeat=#{websockify_hb} $2 &> $log_file & local ws_pid=$! local counter=0