#!/bin/bash

# des jolies couleurs
red=$'\e[1;31m'
grn=$'\e[1;32m'
yel=$'\e[1;33m'
blu=$'\e[1;34m'
mag=$'\e[1;35m'
cyn=$'\e[1;36m'
end=$'\e[0m'

source scripts/pre_runserver.sh

function _end {
  kill -TERM "${runserver}"
  source scripts/post_runserver.sh
}
# fermeture automatique du tunnel LDAP à la termaison du script
trap "_end" EXIT

printf "\n${grn}%s${end}\n" "Lancement du serveur Django..."
poetry run ./backend/manage.py runserver "$@" &
runserver=$!
wait "${runserver}"
