Improve bin/server
This commit is contained in:
30
bin/server
30
bin/server
@@ -1,8 +1,28 @@
|
|||||||
cd bin/dither && \
|
#!/usr/bin/env bash
|
||||||
ROOT=/Users/dce/code/davideisinger.com/content \
|
set -euo pipefail
|
||||||
KEY=/Users/dce/code/davideisinger.com/secret.key \
|
|
||||||
bundle exec ruby dither.rb &
|
|
||||||
|
|
||||||
sleep 1
|
repo_root=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)
|
||||||
|
dither_dir="${repo_root}/bin/dither"
|
||||||
|
|
||||||
|
pushd "${dither_dir}" >/dev/null
|
||||||
|
ROOT="${repo_root}/content" KEY="${repo_root}/secret.key" bundle exec ruby dither.rb &
|
||||||
|
dither_pid=$!
|
||||||
|
popd >/dev/null
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
if kill -0 "${dither_pid}" 2>/dev/null; then
|
||||||
|
kill "${dither_pid}" 2>/dev/null || true
|
||||||
|
wait "${dither_pid}" 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
trap cleanup EXIT INT TERM
|
||||||
|
|
||||||
|
# Wait until the dither server is listening instead of guessing with sleep.
|
||||||
|
for _ in {1..50}; do
|
||||||
|
if (echo >/dev/tcp/localhost/4567) >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 0.1
|
||||||
|
done
|
||||||
|
|
||||||
DITHER_SERVER=http://localhost:4567 hugo server
|
DITHER_SERVER=http://localhost:4567 hugo server
|
||||||
|
|||||||
Reference in New Issue
Block a user