Directory services
contains several configuration files describing various services that must be highly available
(always running).
The configuration service has the following format:
SERVICE_NAME=name
PROGRAM=path_to_the_program
RUN_ARGS=program arguments to pass
HEALTH_ENDPOINT={path}
PORT={port}
ENABLED=true
Your program must start all the services and continuously monitor them using the health endpoints. If 3 continuous
responses from health endpoints do not return 2xx
, then you must restart the service.
Response status can be retrieved by:
HttpURLConnection http = (HttpURLConnection) url.openConnection();
int statusCode = http.getResponseCode();
The health endpoints probing happens every 15 seconds. Your program also accepts the following commands from STDIN
:
show-status
– shows status of all servicesHEALTHY
- last 3 probes were successfulTENTATIVE
- at least 1 error in the last 3 probesDOWN
- all 3 probes failed or the startup was not successfulDISABLED
- service is disabled
disable ${name}
- stop the service and do not attempt to start it againenable ${name}
- enables the disabled service
Copy the server.py
file to /tmp
folder. You can test it yourself from command line by running curl ${URL}
.