Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add live reload functionality #386

Merged
merged 11 commits into from
May 1, 2024
Merged

Conversation

malcolmholmes
Copy link
Contributor

@malcolmholmes malcolmholmes commented Mar 14, 2024

Currently, Grizzly Server does not notice when a file is edited. This PR attempts to add a
livereload feature. When a file is changed on disk (similar to grr watch which it will
likely replace), the dashboard will be reloaded.

Grafana itself has "live" functionality. This PR wires itself into that. Support is currently for dashboards only.

@malcolmholmes malcolmholmes force-pushed the malcolmholmes/live-reload branch 2 times, most recently from 3211c19 to 7e1fa68 Compare April 18, 2024 11:53
@malcolmholmes malcolmholmes marked this pull request as ready for review April 18, 2024 11:55
@malcolmholmes malcolmholmes requested a review from a team as a code owner April 18, 2024 11:55
@malcolmholmes malcolmholmes requested review from K-Phoen and removed request for a team April 18, 2024 11:55
@julienduchesne
Copy link
Member

Grafana itself has its "live" functionality that could be used to achieve that. However,
that is currently for dashboards only. This PR instead attempts to add generic live reload
support by "stealing" code from Hugo.

The PR description is out of date, right? We do use the live feature

@malcolmholmes
Copy link
Contributor Author

Grafana itself has its "live" functionality that could be used to achieve that. However,
that is currently for dashboards only. This PR instead attempts to add generic live reload
support by "stealing" code from Hugo.

The PR description is out of date, right? We do use the live feature

Correct - I just updated the description. Thx

@julienduchesne
Copy link
Member

Basic auth fix here: #432

Copy link
Member

@julienduchesne julienduchesne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! Just the one comment about auth validation

@@ -144,63 +146,43 @@ func (p *Server) Start() error {
r.Post(pattern, p.blockHandler(response))
}
r.Get("/", p.RootHandler)
r.Get("/api/live/ws", livereload.LiveReloadHandlerFunc(upgrader))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Websocket only works with authentication. I added the basic auth support here: #432 but we should probably validate that auth is there (or figure out how to make it work without)

@malcolmholmes malcolmholmes merged commit adbc582 into main May 1, 2024
7 checks passed
@malcolmholmes malcolmholmes deleted the malcolmholmes/live-reload branch May 1, 2024 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants