From aa1f2c5b7177897dd648fbace1aced3f02e2ca31 Mon Sep 17 00:00:00 2001 From: Peter Gerwinski <peter.gerwinski@hs-bochum.de> Date: Tue, 15 Dec 2020 20:41:12 +0100 Subject: [PATCH] trying to make upload.daemon more robust --- lib/pult/pult.daemon | 2 +- lib/pult/upload.daemon | 6 ++---- lib/pult/upload.module | 8 ++++---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/pult/pult.daemon b/lib/pult/pult.daemon index 8c358e3..72e8627 100755 --- a/lib/pult/pult.daemon +++ b/lib/pult/pult.daemon @@ -240,7 +240,7 @@ background_wid=$(xwininfo -root -children | grep "$background_pattern" | awk '{ xdotool set_window --name "Controlled by PULT" "$background_wid" while true; do - nc.openbsd -q 0 -w 10 -l "$pultd_port" | \ + nc.openbsd -q 0 -l "$pultd_port" | \ while read -ra cmd; do m="${cmd[0]}" $debug && echo -e "$0: command = \"${cmd[*]}\"" 1>&2 diff --git a/lib/pult/upload.daemon b/lib/pult/upload.daemon index 52c0815..007e53f 100755 --- a/lib/pult/upload.daemon +++ b/lib/pult/upload.daemon @@ -22,6 +22,7 @@ pointer_windowid="" cleanup () { + rm -rf "$b64_filename" "$lock_filename" if [ -n "$(jobs -p)" ]; then kill $(jobs -p) fi @@ -31,8 +32,7 @@ trap cleanup exit; shopt -s lastpipe -while true; do - nc.openbsd -w 10 -l "$module_daemon_port" | \ +nc.openbsd -l "$module_daemon_port" | \ while read cmd param_x param_y; do echo "cmd = $cmd, param_x = $param_x, param_y = $param_y" if [ "$cmd" = "pointer" ]; then @@ -73,5 +73,3 @@ while true; do echo "... done." fi done - sleep 1s -done diff --git a/lib/pult/upload.module b/lib/pult/upload.module index 44dc2c1..d48621b 100755 --- a/lib/pult/upload.module +++ b/lib/pult/upload.module @@ -31,7 +31,7 @@ img_title="$module_name Image Viewer" cmd="$1" case "$cmd" in start) - rm -rf "$pid_file" "$config_file" "$upload_dir/$filename" "$upload_dir/$error_filename" "$www_dir$download_dir/$filename" + rm -rf "$pid_file" "$config_file" "$upload_dir/$filename" "$upload_dir/$error_filename" "$upload_dir/$lock_filename" "$www_dir$download_dir/$filename" touch "$config_file" echo -e "\$pultd_port = $pultd_port;" >> "$config_file" echo -e "\$module_name = \"$module_name\";" >> "$config_file" @@ -49,12 +49,12 @@ case "$cmd" in sleep 1 echo -e "$0[$channel]: ... okay, let's hope." fi - echo websockify "$module_daemon_port" -- "$daemon" "$module_name" "$channel" \ + echo websockify "$module_daemon_port" --wrap-mode=respawn -- "$daemon" "$module_name" "$channel" \ "$module_daemon_port" "$img_title" \ "$www_dir/$pointer_filename" \ "$upload_dir/$b64_filename" "$upload_dir/$lock_filename" \ "$upload_dir/$filename" - websockify "$module_daemon_port" -- "$daemon" "$module_name" "$channel" \ + websockify "$module_daemon_port" --wrap-mode=respawn -- "$daemon" "$module_name" "$channel" \ "$module_daemon_port" "$img_title" \ "$www_dir/$pointer_filename" \ "$upload_dir/$b64_filename" "$upload_dir/$lock_filename" \ @@ -77,7 +77,7 @@ case "$cmd" in else echo -e "$0[$channel]: stop: not running" fi - rm -rf "$upload_dir/$filename" "$upload_dir/$error_filename" "$www_dir$download_dir/$filename" + rm -rf "$pid_file" "$config_file" "$upload_dir/$filename" "$upload_dir/$error_filename" "$upload_dir/$lock_filename" "$www_dir$download_dir/$filename" ;; defaults) echo "min=false" -- GitLab