-
Notifications
You must be signed in to change notification settings - Fork 2.1k
feat: add cross-platform launcher scripts for easy setup #262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
cwjustice
wants to merge
3
commits into
lfnovo:main
Choose a base branch
from
cwjustice:claude/launch-01TJcAxkrCQui3tdDxgiHxTe
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,164 @@ | ||
| @echo off | ||
| REM Open Notebook Launcher Script for Windows | ||
| REM This script launches all required services for Open Notebook | ||
|
|
||
| setlocal enabledelayedexpansion | ||
|
|
||
| echo. | ||
| echo ___ _ _ _ _ _ | ||
| echo / _ \ _ __ ___ _ __ ^| \ ^| ^| ___ ^| ^|_ ___^| ^|__ ___ ___ ^| ^| __ | ||
| echo ^| ^| ^| ^| '_ \ / _ \ '_ \^| \^| ^|/ _ \^| __/ _ \ '_ \ / _ \ / _ \^| ^|/ / | ||
| echo ^| ^|_^| ^| ^|_) ^| __/ ^| ^| ^| ^|\ ^| (_) ^| ^|^| __/ ^|_) ^| (_) ^| (_) ^| ^< | ||
| echo \___^| .__/ \___^|_^| ^|_^|_^| \_^|\___/ \__\___^|_.__/ \___/ \___/^|_^|\_\ | ||
| echo ^|_^| | ||
| echo. | ||
| echo Open Notebook Launcher | ||
| echo ====================== | ||
| echo. | ||
|
|
||
| REM Check if we're in the right directory | ||
| if not exist "pyproject.toml" ( | ||
| echo [ERROR] Please run this script from the Open Notebook root directory | ||
| exit /b 1 | ||
| ) | ||
|
|
||
| REM Check for required tools | ||
| echo [INFO] Checking for required tools... | ||
|
|
||
| REM Check for uv | ||
| where uv >nul 2>&1 | ||
| if %ERRORLEVEL% NEQ 0 ( | ||
| echo [ERROR] uv is not installed. | ||
| echo Please install uv from: https://astral.sh/uv | ||
| echo. | ||
| echo For Windows, run in PowerShell: | ||
| echo powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" | ||
| exit /b 1 | ||
| ) | ||
| echo [OK] uv found | ||
|
|
||
| REM Check for Node.js | ||
| where node >nul 2>&1 | ||
| if %ERRORLEVEL% NEQ 0 ( | ||
| echo [ERROR] Node.js is not installed. | ||
| echo Please install Node.js 18+ from: https://nodejs.org/ | ||
| exit /b 1 | ||
| ) | ||
| for /f "tokens=*" %%i in ('node --version') do set NODE_VERSION=%%i | ||
| echo [OK] Node.js found (%NODE_VERSION%) | ||
|
|
||
| REM Check for npm | ||
| where npm >nul 2>&1 | ||
| if %ERRORLEVEL% NEQ 0 ( | ||
| echo [ERROR] npm is not installed. | ||
| echo Please install Node.js which includes npm. | ||
| exit /b 1 | ||
| ) | ||
| for /f "tokens=*" %%i in ('npm --version') do set NPM_VERSION=%%i | ||
| echo [OK] npm found (%NPM_VERSION%) | ||
|
|
||
| REM Check for SurrealDB | ||
| where surreal >nul 2>&1 | ||
| if %ERRORLEVEL% NEQ 0 ( | ||
| echo [WARNING] SurrealDB is not installed. | ||
| echo Please install SurrealDB from: https://surrealdb.com/install | ||
| echo. | ||
| echo For Windows, run in PowerShell: | ||
| echo iwr https://windows.surrealdb.com -useb ^| iex | ||
| exit /b 1 | ||
| ) | ||
| echo [OK] SurrealDB found | ||
|
|
||
| REM Check for .env file | ||
| if not exist ".env" ( | ||
| echo [WARNING] .env file not found. | ||
| if exist ".env.example" ( | ||
| echo Creating .env from .env.example... | ||
| copy .env.example .env >nul | ||
| echo [OK] .env file created | ||
| echo [WARNING] Please edit .env and add your API keys before continuing | ||
| pause | ||
| ) else ( | ||
| echo [ERROR] .env.example not found | ||
| exit /b 1 | ||
| ) | ||
| ) else ( | ||
| echo [OK] .env file found | ||
| ) | ||
|
|
||
| REM Install frontend dependencies if needed | ||
| if not exist "frontend\node_modules" ( | ||
| echo [INFO] Installing frontend dependencies... | ||
| cd frontend | ||
| call npm install | ||
| cd .. | ||
| echo [OK] Frontend dependencies installed | ||
| ) else ( | ||
| echo [OK] Frontend dependencies already installed | ||
| ) | ||
|
|
||
| REM Create data directories if they don't exist | ||
| if not exist "notebook_data" mkdir notebook_data | ||
| if not exist "surreal_data" mkdir surreal_data | ||
|
|
||
| echo. | ||
| echo [INFO] Starting Open Notebook services... | ||
| echo. | ||
|
|
||
| REM Start SurrealDB | ||
| echo [INFO] Starting SurrealDB... | ||
| start "SurrealDB" /MIN cmd /c "surreal start --log info --user root --pass root memory > surreal.log 2>&1" | ||
| timeout /t 2 /nobreak >nul | ||
| echo [OK] SurrealDB started (Port: 8000) | ||
|
|
||
| REM Start API | ||
| echo [INFO] Starting API backend... | ||
| start "Open Notebook API" /MIN cmd /c "uv run run_api.py > api.log 2>&1" | ||
| timeout /t 5 /nobreak >nul | ||
| echo [OK] API backend started (Port: 5055) | ||
|
|
||
| REM Start background worker | ||
| echo [INFO] Starting background worker... | ||
| start "Open Notebook Worker" /MIN cmd /c "uv run --env-file .env surreal-commands-worker --import-modules commands > worker.log 2>&1" | ||
| timeout /t 2 /nobreak >nul | ||
| echo [OK] Background worker started | ||
|
|
||
| REM Start frontend | ||
| echo [INFO] Starting Next.js frontend... | ||
| cd frontend | ||
| start "Open Notebook Frontend" /MIN cmd /c "npm run dev > ..\frontend.log 2>&1" | ||
| cd .. | ||
| timeout /t 5 /nobreak >nul | ||
| echo [OK] Next.js frontend started | ||
|
|
||
| REM Display success message | ||
| echo. | ||
| echo ======================================== | ||
| echo Open Notebook is now running! | ||
| echo ======================================== | ||
| echo. | ||
| echo Access the application at: | ||
| echo Frontend: http://localhost:3000 | ||
| echo API: http://localhost:5055 | ||
| echo API Docs: http://localhost:5055/docs | ||
| echo. | ||
| echo Services are running in separate windows. | ||
| echo. | ||
| echo Log files: | ||
| echo - surreal.log | ||
| echo - api.log | ||
| echo - worker.log | ||
| echo - frontend.log | ||
| echo. | ||
| echo To stop all services: | ||
| echo 1. Close all Open Notebook command windows | ||
| echo 2. Or run: taskkill /F /FI "WINDOWTITLE eq Open Notebook*" | ||
| echo. | ||
| echo [INFO] Opening browser... | ||
| timeout /t 3 /nobreak >nul | ||
| start http://localhost:3000 | ||
|
|
||
| echo. | ||
| echo Press any key to view the frontend log... | ||
| pause >nul | ||
| type frontend.log | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,228 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Open Notebook Launcher Script | ||
| # This script launches all required services for Open Notebook | ||
|
|
||
| set -e | ||
|
|
||
| # Colors for output | ||
| RED='\033[0;31m' | ||
| GREEN='\033[0;32m' | ||
| YELLOW='\033[1;33m' | ||
| BLUE='\033[0;34m' | ||
| NC='\033[0m' # No Color | ||
|
|
||
| # Function to print colored output | ||
| print_info() { | ||
| echo -e "${BLUE}ℹ${NC} $1" | ||
| } | ||
|
|
||
| print_success() { | ||
| echo -e "${GREEN}✓${NC} $1" | ||
| } | ||
|
|
||
| print_warning() { | ||
| echo -e "${YELLOW}⚠${NC} $1" | ||
| } | ||
|
|
||
| print_error() { | ||
| echo -e "${RED}✗${NC} $1" | ||
| } | ||
|
|
||
| # Banner | ||
| echo -e "${BLUE}" | ||
| cat << "EOF" | ||
| ___ _ _ _ _ _ | ||
| / _ \ _ __ ___ _ __ | \ | | ___ | |_ ___| |__ ___ ___ | | __ | ||
| | | | | '_ \ / _ \ '_ \| \| |/ _ \| __/ _ \ '_ \ / _ \ / _ \| |/ / | ||
| | |_| | |_) | __/ | | | |\ | (_) | || __/ |_) | (_) | (_) | < | ||
| \___/| .__/ \___|_| |_|_| \_|\___/ \__\___|_.__/ \___/ \___/|_|\_\ | ||
| |_| | ||
| EOF | ||
| echo -e "${NC}" | ||
| echo "Open Notebook Launcher" | ||
| echo "======================" | ||
| echo "" | ||
|
|
||
| # Check if we're in the right directory | ||
| if [ ! -f "pyproject.toml" ]; then | ||
| print_error "Please run this script from the Open Notebook root directory" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Function to check if a command exists | ||
| command_exists() { | ||
| command -v "$1" >/dev/null 2>&1 | ||
| } | ||
|
|
||
| # Check for required tools | ||
| print_info "Checking for required tools..." | ||
|
|
||
| if ! command_exists uv; then | ||
| print_error "uv is not installed. Installing uv..." | ||
| curl -LsSf https://astral.sh/uv/install.sh | sh | ||
| export PATH="$HOME/.local/bin:$PATH" | ||
| fi | ||
| print_success "uv found" | ||
|
|
||
| if ! command_exists node; then | ||
| print_error "Node.js is not installed. Please install Node.js 18+ from https://nodejs.org/" | ||
| exit 1 | ||
| fi | ||
| print_success "Node.js found ($(node --version))" | ||
|
|
||
| if ! command_exists npm; then | ||
| print_error "npm is not installed. Please install Node.js which includes npm." | ||
| exit 1 | ||
| fi | ||
| print_success "npm found ($(npm --version))" | ||
|
|
||
| # Check for SurrealDB | ||
| if ! command_exists surreal; then | ||
| print_warning "SurrealDB is not installed. Installing SurrealDB..." | ||
| curl -sSf https://install.surrealdb.com | sh | ||
| export PATH="/usr/local/bin:$PATH" | ||
| print_success "SurrealDB installed" | ||
| else | ||
| print_success "SurrealDB found ($(surreal version | head -1))" | ||
| fi | ||
|
|
||
| # Check for .env file | ||
| if [ ! -f ".env" ]; then | ||
| print_warning ".env file not found. Creating from .env.example..." | ||
| if [ -f ".env.example" ]; then | ||
| cp .env.example .env | ||
| print_success ".env file created" | ||
| print_warning "Please edit .env and add your API keys before continuing" | ||
| read -p "Press Enter to continue or Ctrl+C to exit and edit .env..." | ||
| else | ||
| print_error ".env.example not found" | ||
| exit 1 | ||
| fi | ||
| else | ||
| print_success ".env file found" | ||
| fi | ||
|
|
||
| # Install frontend dependencies if needed | ||
| if [ ! -d "frontend/node_modules" ]; then | ||
| print_info "Installing frontend dependencies..." | ||
| cd frontend | ||
| npm install | ||
| cd .. | ||
| print_success "Frontend dependencies installed" | ||
| else | ||
| print_success "Frontend dependencies already installed" | ||
| fi | ||
|
|
||
| # Create data directories if they don't exist | ||
| mkdir -p notebook_data surreal_data | ||
|
|
||
| # Function to cleanup on exit | ||
| cleanup() { | ||
| echo "" | ||
| print_info "Shutting down Open Notebook services..." | ||
| pkill -f "surreal start" 2>/dev/null || true | ||
| pkill -f "run_api.py" 2>/dev/null || true | ||
| pkill -f "uvicorn api.main:app" 2>/dev/null || true | ||
| pkill -f "surreal-commands-worker" 2>/dev/null || true | ||
| pkill -f "next dev" 2>/dev/null || true | ||
| sleep 2 | ||
| print_success "All services stopped" | ||
| exit 0 | ||
| } | ||
|
|
||
| # Register cleanup function | ||
| trap cleanup EXIT INT TERM | ||
|
|
||
| # Start services | ||
| echo "" | ||
| print_info "Starting Open Notebook services..." | ||
| echo "" | ||
|
|
||
| # Start SurrealDB | ||
| print_info "Starting SurrealDB..." | ||
| surreal start --log info --user root --pass root memory > /tmp/surrealdb.log 2>&1 & | ||
| SURREAL_PID=$! | ||
| sleep 2 | ||
|
|
||
| if ps -p $SURREAL_PID > /dev/null; then | ||
| print_success "SurrealDB started (PID: $SURREAL_PID, Port: 8000)" | ||
| else | ||
| print_error "Failed to start SurrealDB" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Start API | ||
| print_info "Starting API backend..." | ||
| uv run run_api.py > /tmp/api.log 2>&1 & | ||
| API_PID=$! | ||
| sleep 5 | ||
|
|
||
| if ps -p $API_PID > /dev/null; then | ||
| print_success "API backend started (PID: $API_PID, Port: 5055)" | ||
| else | ||
| print_error "Failed to start API backend. Check /tmp/api.log for details" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Start background worker | ||
| print_info "Starting background worker..." | ||
| uv run --env-file .env surreal-commands-worker --import-modules commands > /tmp/worker.log 2>&1 & | ||
| WORKER_PID=$! | ||
| sleep 2 | ||
|
|
||
| if ps -p $WORKER_PID > /dev/null; then | ||
| print_success "Background worker started (PID: $WORKER_PID)" | ||
| else | ||
| print_error "Failed to start background worker. Check /tmp/worker.log for details" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Start frontend | ||
| print_info "Starting Next.js frontend..." | ||
| cd frontend | ||
| npm run dev > /tmp/frontend.log 2>&1 & | ||
| FRONTEND_PID=$! | ||
| cd .. | ||
| sleep 5 | ||
|
|
||
| if ps -p $FRONTEND_PID > /dev/null; then | ||
| # Try to detect the port | ||
| FRONTEND_PORT=$(grep -oP "localhost:\K\d+" /tmp/frontend.log | head -1) | ||
lfnovo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if [ -z "$FRONTEND_PORT" ]; then | ||
| FRONTEND_PORT="3000" | ||
| fi | ||
| print_success "Next.js frontend started (PID: $FRONTEND_PID, Port: $FRONTEND_PORT)" | ||
| else | ||
| print_error "Failed to start frontend. Check /tmp/frontend.log for details" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Display success message | ||
| echo "" | ||
| echo -e "${GREEN}========================================${NC}" | ||
| echo -e "${GREEN} Open Notebook is now running!${NC}" | ||
| echo -e "${GREEN}========================================${NC}" | ||
| echo "" | ||
| echo "Access the application at:" | ||
| echo -e " ${BLUE}➜${NC} Frontend: ${GREEN}http://localhost:${FRONTEND_PORT}${NC}" | ||
| echo -e " ${BLUE}➜${NC} API: ${GREEN}http://localhost:5055${NC}" | ||
| echo -e " ${BLUE}➜${NC} API Docs: ${GREEN}http://localhost:5055/docs${NC}" | ||
| echo "" | ||
| echo "Process IDs:" | ||
| echo " • SurrealDB: $SURREAL_PID" | ||
| echo " • API: $API_PID" | ||
| echo " • Worker: $WORKER_PID" | ||
| echo " • Frontend: $FRONTEND_PID" | ||
| echo "" | ||
| echo "Logs are available in /tmp/:" | ||
| echo " • /tmp/surrealdb.log" | ||
| echo " • /tmp/api.log" | ||
| echo " • /tmp/worker.log" | ||
| echo " • /tmp/frontend.log" | ||
| echo "" | ||
| print_warning "Press Ctrl+C to stop all services" | ||
| echo "" | ||
|
|
||
| # Keep script running and display logs | ||
| tail -f /tmp/frontend.log | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.