Skip to content
Reload webpage autometically by using websocket server to push file changes and log events to JavaScript client.
Go HTML
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
html
LICENSE
README.md
config.json.example
monitor.go
ws-server.go

README.md

ws-reload

Auto-reload webpage by monitoring files/directories, for web development.

It's a simple Go program to

  • watch one or more files/directories
  • tail (follow) log file
  • start a websocket server and serve events

On client side, a JavaScript to

  • connect to websocket server and listen to events
  • reload page once file/directory changed
  • display content from log file

Background

I wanted a simple way to do reload-on-save when I was working on a PHP project.

Build and Run

Update config.json.example and save as config.json.

(note, directories watch are NOT recursive)

Build

$ go get .
$ go build monitor.go
$ go build ws-server

Run

$ ./ws-server && ./monitor -f config.json

Todo

  • move into package.
  • combine server and monitor as one.
You can’t perform that action at this time.