-
Notifications
You must be signed in to change notification settings - Fork 118
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
Implement a new static
mode
#76
Conversation
This mode allows the users to use the watchdog as a static server for serving static files. The added benefit over a plain file server is that they get the RED metrics already implemented by the watchdog. Signed-off-by: Matias Pan <matias.pan26@gmail.com>
@@ -48,7 +49,7 @@ func (w WatchdogConfig) Process() (string, []string) { | |||
} | |||
|
|||
// New create config based upon environmental variables. | |||
func New(env []string) (WatchdogConfig, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We were not using the error
return value so I thought about removing it and cleanup the code a bit.
Nice work 💪 Please can you show this website operating through the gateway, where there is a prefixed path? Alex |
Please can you also?
|
@@ -338,6 +336,15 @@ func makeHTTPRequestHandler(watchdogConfig config.WatchdogConfig) func(http.Resp | |||
} | |||
} | |||
|
|||
func makeStaticRequestHandler(watchdogConfig config.WatchdogConfig) http.HandlerFunc { | |||
if watchdogConfig.StaticPath == "" { | |||
log.Fatal(`For mode=static you must specify the "static_path" to serve`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense to have a default? I don't know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved
@matipan I would like you to acknowledge the comments and provide the feedback I've asked for. Given that you are the only consume at the moment, I'll merge and release the change, but please can you prioritise the feedback? |
You can access the new release via: https://github.com/openfaas-incubator/of-watchdog/releases/tag/0.5.5 |
This mode allows the users to use the watchdog as a static server for
serving static files. The added benefit over a plain file server is that
they get the RED metrics already implemented by the watchdog.
Signed-off-by: Matias Pan matias.pan26@gmail.com
Description
A new mode was added called
static
. When the users set this mode they must also set thestatic_path
variable that will be the directory the user wants to serve. If none is set we default to/home/app/public
.I also changed the signature of the
config.New
function, it was returning an error but in the function we were never actually returning an error. I updated the tests with this new change.Closes #74
Motivation and Context
When creating the hugo template we noticed that instead of depending on an external static server we could implement this functionality in the watchdog.
How Has This Been Tested?
After making the changes I built the binary and tweaked the hugo template for using the watchdog instead of the static server. I then built my personal blog that uses this template and served it locally with:
You can see that the logs indicate we are making use of the new
static
mode. I then went to http://localhost:8080 and saw that the website was being properly rendered:I also executed
./build.sh
to make sure all of the binaries are being properly built:Output of build.sh:
Types of changes
Checklist:
git commit -s