blob: a421be34f96d372437defd8100110df43358c384 (
plain) (
blame)
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
|
#!/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
|