From faefe473aa0f0202cc9903fb5892486ffc58b3e7 Mon Sep 17 00:00:00 2001 From: Nick Hale <4175918+njhale@users.noreply.github.com> Date: Wed, 16 Oct 2024 14:10:31 -0400 Subject: [PATCH] chore: add dev rule to start otto8 and the admin ui Signed-off-by: Nick Hale <4175918+njhale@users.noreply.github.com> --- Makefile | 6 +++++- dev.sh | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 dev.sh diff --git a/Makefile b/Makefile index 7d50ea944..37d919cc2 100644 --- a/Makefile +++ b/Makefile @@ -19,4 +19,8 @@ clean: build: go build -o bin/otto -v -.PHONY: ui build all clean +dev: ui + @echo "Starting dev otto server and admin UI..." + ./dev.sh + +.PHONY: ui build all clean dev diff --git a/dev.sh b/dev.sh new file mode 100755 index 000000000..775026552 --- /dev/null +++ b/dev.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +cleanup() { + echo "Terminating processes..." + kill 0 +} + +trap cleanup EXIT + +# Start the otto server +go run main.go server --dev-mode 2>&1 | while IFS= read -r line; do + printf "\033[38;5;183m[server]\033[0m %s\n" "$line" +done & +otto_pid=$! + +# Start the admin UI +cd ui/admin && VITE_API_IN_BROWSER=true npm run dev 2>&1 | while IFS= read -r line; do + printf "\033[38;5;153m[admin-ui]\033[0m %s\n" "$line" +done & +npm_pid=$! + +# Wait for both processes to finish +wait "$otto_pid" "$npm_pid"