Make timeouts/heartbeats easy to setup

This commit is contained in:
Pat Riehecky 2020-11-09 13:25:29 -06:00
parent 499eee4d06
commit 5dbacc5e41
1 changed files with 13 additions and 1 deletions

View File

@ -26,6 +26,12 @@ usage() {
echo " --ssl-only Disable non-https connections." echo " --ssl-only Disable non-https connections."
echo " " echo " "
echo " --record FILE Record traffic to FILE.session.js" echo " --record FILE Record traffic to FILE.session.js"
echo " "
echo " --heartbeat SEC send a ping to the client every SEC seconds"
echo " --timeout SEC after SEC seconds exit when not connected"
echo " --idle-timeout SEC server exits after SEC seconds if there are no"
echo " active connections"
echo " " echo " "
exit 2 exit 2
} }
@ -41,6 +47,9 @@ WEB=""
proxy_pid="" proxy_pid=""
SSLONLY="" SSLONLY=""
RECORD_ARG="" RECORD_ARG=""
HEARTBEAT_ARG=""
IDLETIMEOUT_ARG=""
TIMEOUT_ARG=""
die() { die() {
echo "$*" echo "$*"
@ -70,6 +79,9 @@ while [ "$*" ]; do
--web) WEB="${OPTARG}"; shift ;; --web) WEB="${OPTARG}"; shift ;;
--ssl-only) SSLONLY="--ssl-only" ;; --ssl-only) SSLONLY="--ssl-only" ;;
--record) RECORD_ARG="--record ${OPTARG}"; shift ;; --record) RECORD_ARG="--record ${OPTARG}"; shift ;;
--heartbeat) HEARTBEAT_ARG="--heartbeat ${OPTARG}"; shift ;;
--idle-timeout) IDLETIMEOUT_ARG="--idle-timeout ${OPTARG}"; shift ;;
--timeout) TIMEOUT_ARG="--timeout ${OPTARG}"; shift ;;
-h|--help) usage ;; -h|--help) usage ;;
-*) usage "Unknown chrooter option: ${param}" ;; -*) usage "Unknown chrooter option: ${param}" ;;
*) break ;; *) break ;;
@ -162,7 +174,7 @@ fi
echo "Starting webserver and WebSockets proxy on port ${PORT}" echo "Starting webserver and WebSockets proxy on port ${PORT}"
#${HERE}/websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} & #${HERE}/websockify --web ${WEB} ${CERT:+--cert ${CERT}} ${PORT} ${VNC_DEST} &
${WEBSOCKIFY} ${SSLONLY} --web ${WEB} ${CERT:+--cert ${CERT}} ${KEY:+--key ${KEY}} ${PORT} ${VNC_DEST} ${RECORD_ARG} & ${WEBSOCKIFY} ${SSLONLY} --web ${WEB} ${CERT:+--cert ${CERT}} ${KEY:+--key ${KEY}} ${PORT} ${VNC_DEST} ${HEARTBEAT_ARG} ${IDLETIMEOUT_ARG} ${RECORD_ARG} ${TIMEOUT_ARG} &
proxy_pid="$!" proxy_pid="$!"
sleep 1 sleep 1
if ! ps -p ${proxy_pid} >/dev/null; then if ! ps -p ${proxy_pid} >/dev/null; then