Improve check of services, Fix #19 #23
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check of services is now handled by the host using a small PHP script that receives the URL to connect to and checks not only if it is alive, but also checks its status code or returns 502 as fallback. Check the status code is necessary in many cases, especially related to the container world, since the status code can be used to see if a service is really alive or dead (playing with healthcheckers and small services that perform this task, for example).
The checkOnline() function in worker.js has been modified a bit for reuse. I think another approach to implement this feature is to send an identifier to the PHP script that does a read to settings.json to get the URL of the website to check. I think this is a bit more complex, but it only makes sense if the settings.json cannot be modified through the web UI.
service restserver statusstatus code (and other checks) and writing to a small file that another container with a PHP script could read to change the status code returned. Such a container is calledhealthand is just an apache server with PHP support, so the entry point ishttp://health, I usehttp://health/rest-server/in settings.json to check the status code. This sounds a bit complex, but it is very simple, but Dasherr requires interpreting the status code to actually tell me if the service is generating an error or not. See this issue for more details on what I mention.