nginx-hosts-reload is a Go project that monitors changes in the /etc/hosts file and reloads the nginx process when changes are detected.
- Monitors the /etc/hosts file for changes
- Sends a SIGHUP signal to the nginx process when changes are detected
- Provides a simple API to start and stop the monitoring process
To run Nginx Hosts Reload, you must compile the code and run the binary file.
go build
./nginx-hosts-reload
By default, the utility will run in the background and check the modification time of the /etc/hosts file every 5 seconds. The nginx process name and the "master process" cmd substring will be used to find the nginx process ID.
- -log-level: Specify the log level (default: info)
- -interval: Specify the interval for checking the hosts file for changes (default: 5s)
- -process-name: Specify the process name to check (default: nginx)
- -cmd-substring: Specify the cmd substring to check (default: master process)
The Makefile has several options:
- build: Builds the Go project and creates a binary in the bin directory.
- build_amd64: Builds the Go project for the Linux, AMD64 architecture and creates a binary in the bin directory.
- test: Runs vet, unit, and integration targets.
- vet: Runs Go's vet tool to check for suspicious constructs in the source code.
- unit: Runs unit tests on the project.
- integration: Builds a Docker image and runs integration tests.
- image: Builds a Docker image using the Dockerfile in ci/docker directory.
- docker_start: Starts a Docker container with the previously built Docker image and copies the binary to the container.
- docker_stop: Stops and removes the Docker container.
- docker_exec: Runs a bash shell inside the Docker container.
- bosh_release: Creates a BOSH release tarball from the project source code.
- gh_actions: Runs the act tool to emulate github actions locally.
- clean: Deletes the bin directory, the bosh-release-tarballs directory, and some other generated files.
Contributions are welcome. Please open a pull request or issue for any bugs or feature requests.