Allow arbitrary command (via child process?)
sadams opened this issue · comments
I currently use wait-on for http but have to write something separate for other cases.
E.g. because mysql listens on it's port even when it's not ready to accept connections, i do something like this:
#!/usr/bin/env bash
set -e
i=0
while ! mysqladmin ping -h"$DB_HOST" --silent; do
i=$((i+1))
if [[ "$i" -gt '20' ]]; then
echo "mysql failed to start"
exit 1
fi
sleep 1
done
npx wait-on http://somehttpcheck
But if wait-on supported a command
resource i could do this:
npx wait-on http://somehttpcheck "command:mysqladmin ping -h$DB_HOST"
I'm not sure command
is the right naming but hopefully the intention is clear.
@sadams I have the same need. By custom command (CLI) the need is quite easily covered.
@jeffbski is it possible to bump the topic up? Or what @sadams or me (@slavahatnuke) could resolve such a case?
I feel like the protocol could be command:
it describes the thing.
And for example waiting for not-empty directory #96 could look like
- EMPTY:
wait-on command:"find /tmp/to-be-empty -maxdepth 0 -empty | grep tmp/to-be-empty"
- NON-EMPTY:
wait-on command:"find /tmp/to-be-empty -maxdepth 0 | grep tmp/to-be-empty"
It covers a few topics at once in the issues
- #96 =mentioned before find + grep
- #95 =find + grep
- #90 =just curl it
- #71 =ps | grep it
- #15 =ps | grep
For Linux family systems the tool is brilliant.
For Windows, it could take more effort to cover all mentioned needs in the issues.
I feel like a lot of people are using wait-on
in CI/dev/staging environments that are in node.js naturally Linux-based and this solution has a huge impact.
So, wait-on command:"any-command"
looks quite promising and I would like to ask you @jeffbski to help.
@jeffbski I follow up, about improving the functionality of the wait-on command
, could you help with the question or it's needed to be forked?