aboutsummaryrefslogtreecommitdiffstats
path: root/start-dev.sh
diff options
context:
space:
mode:
authorxuatz <xzlow10@gmail.com>2025-06-21 18:38:57 +0900
committerGitHub <noreply@github.com>2025-06-21 10:38:57 +0100
commit88e4ea98c5f57fa4124285cb3eab75e2c04b9740 (patch)
treee9c719a51b42c8f285de95a32048ce2146451ee7 /start-dev.sh
parent004eb5ad0d986b093fc5b79ca1011c69abf8ad73 (diff)
downloadkarakeep-88e4ea98c5f57fa4124285cb3eab75e2c04b9740.tar.zst
chore: add start-dev.sh for laziness (#1628)
* chore: add start-dev.sh for laziness * include chrome in start-dev.sh
Diffstat (limited to 'start-dev.sh')
-rwxr-xr-xstart-dev.sh77
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