DarthSim / overmind

Process manager for Procfile-based applications and tmux
MIT License
2.78k stars 79 forks source link

"sleep pause" commands is anti pattern in procfile ? #145

Open gedw99 opened 1 year ago

gedw99 commented 1 year ago

this is working very well on mac . really useful tool.

I was wondering about startup dependency ordering, and am looking for advice.

I read in the issues about users wanting a sleep function to force the procfile processing to wait for something to start. But it seems like an anti pattern. Better to design your calling binaries to try to connect to something else and then back off and try again ?

DarthSim commented 1 year ago

Procfile is a very simple format that doesn't support health checks. Applications that use it can't determine the readiness of processes and thus can't make processes wait for their dependencies' readiness.

In this situation, sleep is the easiest solution, yet it's not ideal.

Changing your application so it retries connection to its dependency is a good solution, yet it's not always possible to change your application like this.

So I think the best solution is to use some kind of tool or wrapper that waits for dependency readiness before starting a process. For example, the wait-for-it script can wait until it can connect to the requested port.

gedw99 commented 1 year ago

A golang equivalent o wait for it would be good.

Can then wrap any program with it. Sort of like a proxy ..

I used aqua proxy for this once and it might work well with overmind. it’s gets a binary if it’s not there and then let’s the caller call it. Basically serverless pattern.

The same sort of thing for a socket is needed. Caller asks and proxy waits for the socket to be there and then lets the call through .

gedw99 commented 1 year ago

Golang equivalent

https://github.com/roerohan/wait-for-it

gedw99 commented 1 year ago

Also

https://github.com/atkrad/wait4x