TL;DR: $ ssereload 1333 &; find -f build | entr -s 'pkill -HUP ssereload' Live reload, that is, automatic reload of a browser tab when the source files had changed, is a nice thing. It shortens the feedback loop, whether you are iterating on layout, styles, or the content. Usually this feature is built-in in the SSG, but if you’re building your own generator, then, unsurprisingly, you’d have to build it too. It’s not that critical a feature that you can’t live without, a nice to have, and it’s not that hard to build. I’ve been nerdsniped^W inspired by a few comments on Lobsters to try to separate this feature from website generator proper. I really like using entr for watching the file changes: it does one thing and it fits in my head. So I’ve even gone one step further than separating reload from SSG: ssereload doesn’t watch the files, it only listens to a SIGHUP. The plan was simple: set up signal handler, in which notify current connections about the signal. I’ve decided to try writing it in Scheme, in order to learn it as well. Source code Long story short, here is the source code: (import (chicken io) (chicken tcp) (chicken process signal) (chicken process-context) (chicken condition) (srfi-1)) (define port-for-sse (string->number (car (append (command-line-arguments) '("1330"))))) (define (hup-handler _) (notify-listeners)) (define (int-handler _) (set! should-quit #t) (notify-listeners) (exit)) (define should-quit? #f) (define listeners (list)) (define (notify-listeners) (write-line "ssereload: reloading listeners") (set! listeners (filter (lambda (x) (x)) listeners))) (define (write-single-update out) (condition-case (begin (write-line "data: reload\r\n\r\n" out) (flush-output out) (if should-quit? (begin (close-output-port out) #f) #t)) ((exn i/o net) #f))) (define (accept-loop listener) (unless should-quit? (let-values (((i o) (tcp-accept listener))) (let ((inp (read-line i))) (begin (close-input-port i) (if (string=? inp "GET /sse HTTP/1.1") (set-up-liste...
First seen: 2026-03-26 21:15
Last seen: 2026-03-27 22:32