Add a dev script #9

Merged
a3thakra merged 1 commits from adi-dev-script into main 2 years ago
  1. 47
      dev.sh

@ -0,0 +1,47 @@
#!/usr/bin/env bash
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m'
function prefix_stdout_stderr() {
exec > >(trap "" INT TERM; sed "s/^/`printf "$1"`/")
exec 2> >(trap "" INT TERM; sed "s/^/`printf "$1"`/" >&2)
}
function start_frontend() {
prefix_stdout_stderr "${PURPLE}frontend: ${NC}"
cd ./frontend
npm run dev
}
function start_backend() {
prefix_stdout_stderr "${CYAN}backend: ${NC}"
cd ./backend
source venv/bin/activate
echo $(which python)
python main.py
}
start_frontend &
pid_frontend=$!
start_backend &
pid_backend=$!
trap_ctrlc() {
echo ""
kill $pid_frontend
echo "frontend exit code: $?"
kill $pid_backend
echo "backend exit code: $?"
}
trap trap_ctrlc INT
wait
Loading…
Cancel
Save