From a1516a67bccedf04617023bd1763a12c306c762a Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 22 Jul 2019 15:47:13 +0100 Subject: [PATCH] build: Add development web server build tasks --- build | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/build b/build index 307745f..dbab9c6 100755 --- a/build +++ b/build @@ -161,6 +161,36 @@ task_client-watch() { } +# ██████ ███████ ██ ██ ███████ ███████ ██████ ██ ██ ███████ ██████ +# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +# ██ ██ █████ ██ ██ █████ ███████ █████ ██████ ██ ██ █████ ██████ +# ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ +# ██████ ███████ ████ ███████ ███████ ██ ██ ████ ███████ ██ ██ + +task_dev-server() { + task_begin "Starting development server"; + php -S "[::1]:40382" -t "app" & + exit_code=$?; + [[ "${exit_code}" -eq "0" ]] && echo $! >/tmp/summer-project-dev-server.pid; + task_end $?; # Should be 0 unless php died for some reason + sleep 1; +} + +task_dev-server-stop() { + task_begin "Stopping development server"; + + if [ ! -f "/tmp/summer-project-dev-server.pid" ]; then + echo -e "${HC}${FRED}Error: The development server doesn't appear to be running, so it can't be stopped. Have you tried running ./build dev-server?${RESET}"; + return 1; + fi + + kill "$(cat /tmp/summer-project-dev-server.pid)"; + rm /tmp/summer-project-dev-server.pid; + + task_end $?; +} + + ###############################################################################