Dasherr icon indicating copy to clipboard operation
Dasherr copied to clipboard

Improve check of services, Fix #19

Open DtxdF opened this issue 1 year ago • 0 comments

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.


  • This function requires the cURL extension.
  • I was motivated to implement this feature when I deployed rest-server on my FreeBSD server. rest-server listens like any web application, the problem is when you send a request (GET) as it returns a number other than 200-299, so I used a healthchecker that checks if rest-server is alive by checking the service restserver status status 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 called health and is just an apache server with PHP support, so the entry point is http://health, I use http://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.

DtxdF avatar Dec 06 '23 13:12 DtxdF