-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstartup.bat
83 lines (74 loc) · 2.34 KB
/
startup.bat
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
@echo off
::Place this file in the root folder of the project
:: sends contents from logo.txt to the console
type boot_utilities\logo.txt
echo:
set condapath=C:\%homepath%\miniconda3\Scripts\activate.bat
set envname=Text2Map
set repopath=.
rem Check if conda is system installation or user installation
if exist %condapath% (
echo Conda found in user directory
) else if exist C:\programdata\miniconda3 (
set condapath=C:\programdata\miniconda3\Scripts\activate.bat
echo Conda found in system directory
) else (
echo Conda not found
exit /b
)
rem Check if front and backend folders exists
if not exist %repopath%\frontend (
echo Frontend folder not found
exit /b
)
if not exist %repopath%\backend (
echo Backend folder not found
exit /b
)
rem Check if .env.local file exists
if not exist %repopath%\frontend\.env.local (
call boot_utilities\create_env.bat
)
rem try to start conda base environment
call %condapath% base
if %errorlevel% equ 0 (
echo Conda base environment is now active.
) else (
echo Conda base environment could not be activated/start or does not exist.
exit /b
)
rem Check if Conda environment exists
call conda info --envs | findstr /i "\<%envname%\>" > nul
if %errorlevel% equ 0 (
rem Environment exists, activate it
echo Activating existing Conda environment: %envname%
call %condapath% %envname%
) else (
rem Environment doesn't exist, create and activate it
echo Creating and activating new Conda environment: %envname%
call conda create --name %envname% python=3.8
call conda activate %envname%
call conda install -q --yes yarn
call conda install -q --yes pip
)
echo Conda environment %envname% is now active.
rem Starts the frontend and backend in separate cmd windows
start cmd /k "cd %repopath%\frontend && yarn install -s && yarn dev"
start cmd /k "cd %repopath%\backend && pip install --quiet -r requirements.txt && uvicorn main:app --reload"
rem check if server is running every second if not successfull after 20 seconds exit, if successfull open browser
setlocal
set /a count=0
:loop
timeout /t 1 >nul
set /a count+=1
curl -s http://localhost:3000 >nul
if %errorlevel% equ 0 (
start "" http://localhost:8000/docs
start "" http://localhost:3000
exit /b
) else if %count% geq 20 (
echo Server could not be started
exit /b
) else (
goto loop
)