proophboard / cody-engine

Event Modeling meets prototyping
https://wiki.prooph-board.com/cody_engine/introduction.html
MIT License
10 stars 6 forks source link

Perform server health check after Cody hook #32

Open codeliner opened 1 year ago

codeliner commented 1 year ago

npm run serve uses Nx to start backend, frontend and cody servers within one go. Unfortunately, the watch mode of backend and frontend servers do not work reliable all the time.

Sometimes a TS error occurs, because the user on prooph board did not trigger Cody with all needed information (which is a totally valid use case). As soon as information is complete, the servers should restart automatically and continue to serve the app. We cannot rely on the watch mode alone, because it does not always recover from compile time errors.

Instead we need to start all servers through our own "serve" script so that we have control over the child processes of the servers. It should be possible to trigger a restart of the servers with a helper function that can be used from a Cody Hook.

Then we can do a health check at the end of each Cody Hook and if it fails, let the script restart the servers to see if it solves the issue.

The backend server provides a health check endpoint: http://localhost:4100/health And frontend could be checked by requesting http://localhost:4200/dashboard and see if a status code 200 is returned along with a non empty body