Skip to content

Server to stream a JSON file over Server-Sent-Events (SSE) to a client/browser.

License

Notifications You must be signed in to change notification settings

politie/sseserver

Repository files navigation

sseserver Build Status Go Report Card

Server to stream a JSON file over Server-Sent-Events (SSE) to a client/browser.

Build

Install Go as described: https://golang.org/doc/install and then:

make dev-dependencies
make release 

Test

make test

Run

./sseserver-<os>-<arch> -inputFile <file-to-serve>

Open examples/test_sse.html to receive the SSE events.

Resend file to all connected clients

kill -HUP <PID of sseserver>

Use with Consul Template

The sseserver works nicely when combined with Consul Template to stream information from Consul to clients/browsers.

./consul-template \
-template=/endpoints.ctmpl:/endpoints.json \
-exec='./sseserver -enable-syslog -context /endpoints -input-file /endpoints.json' \
-exec-reload-signal=SIGHUP

Contributors