Skip to content

Reevaluate "_redirections" when file changes #127

@patrickdappollonio

Description

@patrickdappollonio

Currently, when the server starts, the _redirections file gets loaded and the rules parsed.

If, during the time http-server has been running the _redirections file changes, those changes are not reflected as rule changes in the redirection system unless you restart http-server like, an index.html file served from the directory would normally change and its changes picked up.

We should be able to detect changes to the _redirections file or, alternatively, a way to let http-server know that file changed.

While I would prefer to detect changes to the file using a file watcher, I know finding a cross-platform solution is a bit challenging. We do have binaries for darwin, linux and windows (in ARM and x86_64 flavours) so we might just have to support those.

The other option described is to support a signal, a la Nginx or other servers where, if you send, say SIGUSR1 then you reload the _redirections file.

While in the past I've been against using watchers for configuration (I would prefer in those cases to get a fresh start), _redirections seems to warrant it more than others.

The caveat here is that if we detect changes on the file, and the file changes, and bad rules are configured, we should continue using the old rules but warn in the terminal that the rules file is invalid and we would continue to use the old rules.

Metadata

Metadata

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions