File tree Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Expand file tree Collapse file tree 1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -368,8 +368,16 @@ writeHttpResponse() {
368368 header Content-Type " text/event-stream"
369369 end_headers
370370 output () {
371+ killthehmr () {
372+ kill " $HMR_PID " & > /dev/null
373+ wait " $HMR_PID " & > /dev/null
374+ exit 0
375+ }
376+ trap ' killthehmr' TERM
371377 while true ; do
372- inotifywait -e MODIFY -r pages static & > /dev/null
378+ inotifywait -e MODIFY -r pages static & > /dev/null &
379+ HMR_PID=$!
380+ wait " $HMR_PID " & > /dev/null
373381 event " reload"
374382 done
375383 }
@@ -381,8 +389,8 @@ writeHttpResponse() {
381389 :
382390 done
383391
384- kill -9 $PID & > /dev/null
385- wait $PID 2 > /dev/null
392+ kill $PID & > /dev/null
393+ wait $PID & > /dev/null
386394
387395 return
388396 elif [[ -z " $ROUTE_SCRIPT " ]]; then
@@ -405,8 +413,16 @@ writeHttpResponse() {
405413 fi
406414 SUB_FD=$( subscribe " $TOPIC " )
407415 output () {
416+ killthecat () {
417+ kill " $CAT_PID " & > /dev/null
418+ wait " $CAT_PID " & > /dev/null
419+ exit 0
420+ }
421+ trap ' killthecat' TERM
408422 while true ; do
409- cat " $SUB_FD "
423+ cat " $SUB_FD " &
424+ CAT_PID=$!
425+ wait " $CAT_PID " & > /dev/null
410426 done
411427 }
412428 output &
@@ -418,8 +434,8 @@ writeHttpResponse() {
418434 :
419435 done
420436
421- kill -9 $PID & > /dev/null
422- wait $PID 2 > /dev/null
437+ kill " $PID " & > /dev/null
438+ wait " $PID " & > /dev/null
423439
424440 unsubscribe " $SUB_FD "
425441 [[ $( type -t on_close) == function ]] && on_close 1>&2
You can’t perform that action at this time.
0 commit comments