: nply/liveside

1 
2 
3 
4 
5 
6 
7 
8 
9 
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
.Dd September 1, 2026
.Dt LIVESIDE 1
.Os
.Sh NAME
.Nm liveside
.Nd tiny live-reload server using Server-Sent Events
.Sh SYNOPSIS
.Nm
.Op Fl h
.Op Fl p Ar port
.Op Fl d Ar watch-dir
.Op Fl c Ar build-cmd
.Op Fl i Ar poll-ms
.Sh DESCRIPTION
.Nm
watches a directory tree for changes and notifies connected browsers over
Server-Sent Events \&(SSE).  The browser client reloads the page when it
receives a reload event.
.Pp
.Nm
is not a static file server.
It only serves the SSE endpoint and its small browser client script; use it
alongside another server such as
.Nm python3
with
.Fl m Li http.server ,
.Nm darkhttpd ,
or any other site server.
.Pp
To use it, include the client script in the page being developed:
.Bd -literal -offset indent
<script src="http://localhost:8081/liveside.js"></script>
.Ed
.Pp
The client reconnects automatically and reloads the page whenever
.Nm
detects a relevant file change.
.Sh IMPLEMENTATION NOTES
On macOS, FreeBSD, NetBSD, OpenBSD, and DragonFly BSD,
.Nm
uses kqueue.
On Linux it uses inotify.
On Windows it uses ReadDirectoryChangesW.
On other platforms it falls back to polling file names, modification times,
and sizes.
.Pp
Ignore rules are loaded from nested
.Pa .gitignore
and
.Pa .livesideignore
files.
.Sh OPTIONS
.Bl -tag -width Ds
.It Fl p Ar port
Serve the HTTP/SSE endpoints on
.Ar port .
The default is 8081.
.It Fl d Ar watch-dir
Watch
.Ar watch-dir
recursively.
The default is the current directory.
.It Fl c Ar build-cmd
Run
.Ar build-cmd
before notifying browsers.
If the command exits non-zero, clients are not reloaded.
.It Fl i Ar poll-ms
Set the polling interval in milliseconds for platforms without a native watcher
backend.
The default is 300.
This option is only used by the polling fallback.
.It Fl h
Print usage information and exit.
.El
.Sh ENDPOINTS
.Bl -tag -width /livereload
.It Pa /livereload
SSE stream used by browser clients.
.It Pa /liveside.js
Browser client script served by
.Nm .
.It Pa /
Plain-text status page.
.El
.Sh EXIT STATUS
.Ex -std
.Sh EXAMPLES
Run liveside beside another local site server:
.Bd -literal -offset indent
$ ./liveside -d ./site -p 8081
.Ed
.Pp
Run a build command before each reload:
.Bd -literal -offset indent
$ ./liveside -d ./site -c 'make all'
.Ed
.Pp
Serve the actual site separately, for example:
.Bd -literal -offset indent
$ python3 -m http.server 8000
.Ed
.Sh SEE ALSO
.Xr sh 1
.Sh AUTHORS
.An saikrupa