File tree 1 file changed +22
-6
lines changed
1 file changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -368,8 +368,16 @@ writeHttpResponse() {
368
368
header Content-Type " text/event-stream"
369
369
end_headers
370
370
output () {
371
+ killthehmr () {
372
+ kill " $HMR_PID " & > /dev/null
373
+ wait " $HMR_PID " & > /dev/null
374
+ exit 0
375
+ }
376
+ trap ' killthehmr' TERM
371
377
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
373
381
event " reload"
374
382
done
375
383
}
@@ -381,8 +389,8 @@ writeHttpResponse() {
381
389
:
382
390
done
383
391
384
- kill -9 $PID & > /dev/null
385
- wait $PID 2 > /dev/null
392
+ kill $PID & > /dev/null
393
+ wait $PID & > /dev/null
386
394
387
395
return
388
396
elif [[ -z " $ROUTE_SCRIPT " ]]; then
@@ -405,8 +413,16 @@ writeHttpResponse() {
405
413
fi
406
414
SUB_FD=$( subscribe " $TOPIC " )
407
415
output () {
416
+ killthecat () {
417
+ kill " $CAT_PID " & > /dev/null
418
+ wait " $CAT_PID " & > /dev/null
419
+ exit 0
420
+ }
421
+ trap ' killthecat' TERM
408
422
while true ; do
409
- cat " $SUB_FD "
423
+ cat " $SUB_FD " &
424
+ CAT_PID=$!
425
+ wait " $CAT_PID " & > /dev/null
410
426
done
411
427
}
412
428
output &
@@ -418,8 +434,8 @@ writeHttpResponse() {
418
434
:
419
435
done
420
436
421
- kill -9 $PID & > /dev/null
422
- wait $PID 2 > /dev/null
437
+ kill " $PID " & > /dev/null
438
+ wait " $PID " & > /dev/null
423
439
424
440
unsubscribe " $SUB_FD "
425
441
[[ $( type -t on_close) == function ]] && on_close 1>&2
You can’t perform that action at this time.
0 commit comments