-
Notifications
You must be signed in to change notification settings - Fork 6
/
start.sh
61 lines (51 loc) · 1.16 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/bash
# Varialbles
Version="0.3.3"
White="\033[1;37m"
Red="\033[1;31m"
Reset="\033[0m"
# Message handler functions
function prs() {
echo -e "$White ==> $1 $Reset"
}
function error() {
echo -e "$Red Unhandled argument: $1 $Reset"
}
function checkDepends() {
is_uvicorn=$(command -v uvicorn &> /dev/null)
if ! $is_uvicorn ; then
echo "${Red}Uvicorn is not installed 😥 $Reset"
exit
fi
}
function startServer() {
if [ "$1" == true ] ; then
uvicorn api.main:app --reload
else
uvicorn api.main:app
fi
}
function main() {
clear
isDev=false
if [ "$1" == dev ] ; then
isDev=true
echo -e "$White Nexa API 🌊 - Dev Mode ($Version) $Reset\n\n "
case "$2" in
-u|--update)
pip3 install -U -r requirements.txt; shift ;;
"")
shift ;;
*)
error "$2"
esac
else
echo -e "$White Nexa API 🌊 - $Version $Reset\n\n "
fi
prs "Checking Dependencies 🔎..."
checkDepends
prs "All done ✅"
prs "Starting the server 📡..."
startServer $isDev
}
main "$1" "$2"