Asynchronous signal for processes orchestration
On a bash script, you sometimes require to send jobs to the background. If you want that background process to somehow signal that it's finished its setup and it's ready for the main process to use one of good idea is to make the background process bind to a port that acts as a signal to the main process. The main process can simply wait on such process to open (#686) asynchronously and then continue.
Example usage:
- The main process starts an S3 server on the background
- The main process waits for port 19000 to open
- The S3 server starts listening on port 9000
- The S3 server does some initial setup
- The S3 signals that it's ready and functional by opening port 19000
- The main process resumes as port 19000 is done
As you can see, waiting for port 9000 directly is a bad idea, as the main script would continue working with a not-ready S3 server. Normally people here would a $ sleep. But this is worst as things take more/less depending on CPU speed, network bandwidth, kernel load factor, etc
Example implementation:
- https://gitlab.com/fluidattacks/product/-/tree/708bb9d1662b8431c2439d540465c72167b9b719/makes/applications/makes/done
This contributes to a world where people do not perform processes orchestration with poorman's $ sleeps
related to #686