Skip to content

Commit

Permalink
new ps script
Browse files Browse the repository at this point in the history
  • Loading branch information
adenjonah committed May 16, 2024
1 parent 8461ee1 commit 0dabe9e
Showing 1 changed file with 26 additions and 36 deletions.
62 changes: 26 additions & 36 deletions run_lmcc_windows.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
# Get the directory of the current script
$SCRIPT_DIR = Split-Path -Parent $MyInvocation.MyCommand.Definition

# Function to check and install Python
function Install-Python {
if (-not (Get-Command python3 -ErrorAction SilentlyContinue)) {
Write-Output "Python3 could not be found. Installing Python3..."
Invoke-WebRequest -Uri https://www.python.org/ftp/python/3.9.5/python-3.9.5-amd64.exe -OutFile python-installer.exe
Start-Process -FilePath python-installer.exe -ArgumentList '/quiet InstallAllUsers=1 PrependPath=1' -Wait
Remove-Item python-installer.exe
if ($IsLinux) {
sudo apt update
sudo apt install -y python3 python3-pip
} elseif ($IsMacOS) {
# Check if Homebrew is installed, install if not
if (-not (Get-Command brew -ErrorAction SilentlyContinue)) {
Write-Output "Homebrew could not be found. Installing Homebrew..."
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
}
brew install python3
} elseif ($IsWindows) {
Write-Output "Please install Python3 manually on Windows from https://www.python.org/downloads/"
exit 1
} else {
Write-Output "Unknown OS type. Please install Python3 manually."
exit 1
}
} else {
Write-Output "Python3 is already installed."
}
Expand All @@ -13,26 +30,7 @@ function Install-Python {
# Function to install Python dependencies
function Install-PythonDependencies {
Write-Output "Installing Python dependencies..."
pip3 install -r requirements.txt
}

# Function to check and install Docker
function Install-Docker {
if (-not (Get-Command docker -ErrorAction SilentlyContinue)) {
Write-Output "Docker could not be found. Installing Docker..."
Invoke-WebRequest -Uri https://desktop.docker.com/win/stable/Docker%20Desktop%20Installer.exe -OutFile docker-installer.exe
Start-Process -FilePath docker-installer.exe -ArgumentList '/quiet' -Wait
Remove-Item docker-installer.exe
} else {
Write-Output "Docker is already installed."
}
}

# Function to run Docker container
function Run-DockerContainer {
Write-Output "Running Docker container..."
docker build -t tss_2024 .
docker run -it -p 14141:14141 --name tss_2024 tss_2024
pip3 install -r "$SCRIPT_DIR\requirements.txt"
}

# Check and install Python
Expand All @@ -41,22 +39,14 @@ Install-Python
# Install Python dependencies
Install-PythonDependencies

# Check and install Docker
Install-Docker

# Run Docker container
Start-Job -ScriptBlock {
Run-DockerContainer
}

# Installing npm dependencies
# Install npm dependencies
Write-Output "Installing npm dependencies..."
npm install

# Starting the server
# Start the server
Write-Output "Starting the server with npm start..."
Start-Process -NoNewWindow npm start
Start-Process -NoNewWindow -FilePath "npm" -ArgumentList "start"

# Starting the FastAPI server
# Start the FastAPI server
Write-Output "Starting the FastAPI server with uvicorn..."
Start-Process -NoNewWindow uvicorn server:app --host 0.0.0.0 --port 8000 --reload
Start-Process -NoNewWindow -FilePath "uvicorn" -ArgumentList "server.server:app --host 0.0.0.0 --port 8000 --reload"

0 comments on commit 0dabe9e

Please sign in to comment.