diff options
Diffstat (limited to 'start-dev.sh')
| -rwxr-xr-x | start-dev.sh | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/start-dev.sh b/start-dev.sh new file mode 100755 index 00000000..a421be34 --- /dev/null +++ b/start-dev.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# Function to check if a command exists +command_exists() { + command -v "$1" >/dev/null 2>&1 +} + +# Function to check if a port is in use +port_in_use() { + lsof -i :"$1" >/dev/null 2>&1 +} + +# Check if Docker is installed +if ! command_exists docker; then + echo "Error: Docker is not installed. Please install Docker first." + exit 1 +fi + +# Check if pnpm is installed +if ! command_exists pnpm; then + echo "Error: pnpm is not installed. Please install pnpm first." + exit 1 +fi + +# Start Meilisearch if not already running +if ! port_in_use 7700; then + echo "Starting Meilisearch..." + docker run -d -p 7700:7700 --name karakeep-meilisearch getmeili/meilisearch:v1.13.3 +else + echo "Meilisearch is already running on port 7700" +fi + +# Start Chrome if not already running +if ! port_in_use 9222; then + echo "Starting headless Chrome..." + docker run -d -p 9222:9222 --name karakeep-chrome gcr.io/zenika-hub/alpine-chrome:123 \ + --no-sandbox \ + --disable-gpu \ + --disable-dev-shm-usage \ + --remote-debugging-address=0.0.0.0 \ + --remote-debugging-port=9222 \ + --hide-scrollbars +else + echo "Chrome is already running on port 9222" +fi + +# Install dependencies if node_modules doesn't exist +if [ ! -d "node_modules" ]; then + echo "Installing dependencies..." + pnpm install +fi + +# Start the web app and workers in parallel +echo "Starting web app and workers..." +pnpm web & WEB_PID=$! +pnpm workers & WORKERS_PID=$! + +# Function to handle script termination +cleanup() { + echo "Shutting down services..." + kill $WEB_PID $WORKERS_PID 2>/dev/null + docker stop karakeep-meilisearch karakeep-chrome 2>/dev/null + docker rm karakeep-meilisearch karakeep-chrome 2>/dev/null + exit 0 +} + +# Set up trap to catch termination signals +trap cleanup SIGINT SIGTERM + +echo "Development environment is running!" +echo "Web app: http://localhost:3000" +echo "Meilisearch: http://localhost:7700" +echo "Chrome debugger: http://localhost:9222" +echo "Press Ctrl+C to stop all services" + +# Wait for user interrupt +wait |
