Is there a common utility (Ubuntu, perhaps OSX) that can run a server serve ./public, then run some tests ./run-chrome-tests.sh, and once the tests are finished, kills the serve ./public.

This can be done in bash, but I'd rather create configuration, than code if it is feasible.


There is to my knowledge no such utility, but it is easily implemented in a shell script.

A short shell script that implements what you described:


serve ./public & serve_pid=$!

kill "$serve_pid"

You may want to insert a sleep 3 call (or similar) after starting serve in the background, to allow it to initialize properly before running the testing script.

$! will be the PID of the most recently started background job (the serve process). When the run-chrome-tests.sh script finishes, the script above will explicitly terminate the serve process by signalling using kill.

| improve this answer | |
  • Ah, that is even simpler than the bash I had envisioned...very nice. Accepted because this is what I'll end up doing even though it wasn't exactly what i asked for. – Ashley Coolman Feb 8 '18 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.