add resizing
This commit is contained in:
+59
-7
@@ -13,11 +13,18 @@ NC='\033[0m' # No Color
|
||||
|
||||
BACKEND_PID=""
|
||||
FRONTEND_PID=""
|
||||
WATCHER_PID=""
|
||||
NREPL_PORT=7888
|
||||
|
||||
cleanup() {
|
||||
echo -e "\n${YELLOW}Shutting down...${NC}"
|
||||
|
||||
# Kill file watcher
|
||||
if [ -n "$WATCHER_PID" ]; then
|
||||
pkill -P $WATCHER_PID 2>/dev/null || true
|
||||
kill $WATCHER_PID 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Kill backend and all its children
|
||||
if [ -n "$BACKEND_PID" ]; then
|
||||
pkill -P $BACKEND_PID 2>/dev/null || true
|
||||
@@ -45,20 +52,32 @@ cleanup() {
|
||||
|
||||
trap cleanup SIGINT SIGTERM SIGHUP EXIT
|
||||
|
||||
# Check for clj-nrepl-eval (required for auto-reload)
|
||||
HAS_NREPL_EVAL=true
|
||||
if ! command -v clj-nrepl-eval &> /dev/null; then
|
||||
echo -e "${YELLOW}Warning: clj-nrepl-eval not found. Auto-reload will be disabled.${NC}"
|
||||
HAS_NREPL_EVAL=false
|
||||
fi
|
||||
|
||||
# Check for inotifywait (preferred) or fall back to polling
|
||||
HAS_INOTIFY=false
|
||||
if command -v inotifywait &> /dev/null; then
|
||||
HAS_INOTIFY=true
|
||||
fi
|
||||
|
||||
echo -e "${BLUE}=== Starting Spiceflow Development Environment ===${NC}\n"
|
||||
|
||||
# Start backend REPL with auto-reload
|
||||
echo -e "${GREEN}Starting backend REPL with auto-reload...${NC}"
|
||||
# Start backend REPL
|
||||
echo -e "${GREEN}Starting backend REPL...${NC}"
|
||||
cd "$ROOT_DIR/server"
|
||||
|
||||
# Start nREPL server and run (go) to start app with file watcher
|
||||
# Start nREPL server and run (start) - no hawk watcher, we use inotifywait instead
|
||||
clj -M:dev -e "
|
||||
(require 'nrepl.server)
|
||||
(def server (nrepl.server/start-server :port $NREPL_PORT))
|
||||
(println \"nREPL server started on port $NREPL_PORT\")
|
||||
(require 'user)
|
||||
(user/go)
|
||||
;; Block forever to keep the process running
|
||||
(user/start)
|
||||
@(promise)
|
||||
" &
|
||||
BACKEND_PID=$!
|
||||
@@ -70,7 +89,40 @@ until curl -s http://localhost:3000/api/health > /dev/null 2>&1; do
|
||||
done
|
||||
echo -e "${GREEN}Backend ready on http://localhost:3000${NC}"
|
||||
echo -e "${GREEN}nREPL available on port $NREPL_PORT${NC}"
|
||||
echo -e "${GREEN}Auto-reload enabled - editing .clj files will trigger reload${NC}"
|
||||
|
||||
# Start file watcher for auto-reload
|
||||
if [ "$HAS_NREPL_EVAL" = true ]; then
|
||||
echo -e "${GREEN}Starting file watcher for auto-reload...${NC}"
|
||||
if [ "$HAS_INOTIFY" = true ]; then
|
||||
# Use inotifywait (efficient, event-based)
|
||||
(
|
||||
cd "$ROOT_DIR/server"
|
||||
while inotifywait -r -e modify,create,delete --include '.*\.clj$' src/ 2>/dev/null; do
|
||||
echo -e "${YELLOW}File change detected, reloading...${NC}"
|
||||
clj-nrepl-eval -p $NREPL_PORT "(user/reset)" > /dev/null 2>&1 &
|
||||
done
|
||||
) &
|
||||
WATCHER_PID=$!
|
||||
else
|
||||
# Fallback: polling with find (works everywhere)
|
||||
(
|
||||
cd "$ROOT_DIR/server"
|
||||
LAST_HASH=""
|
||||
while true; do
|
||||
CURRENT_HASH=$(find src -name '*.clj' -exec stat -c '%Y %n' {} \; 2>/dev/null | md5sum)
|
||||
if [ -n "$LAST_HASH" ] && [ "$CURRENT_HASH" != "$LAST_HASH" ]; then
|
||||
echo -e "${YELLOW}File change detected, reloading...${NC}"
|
||||
clj-nrepl-eval -p $NREPL_PORT "(user/reset)" > /dev/null 2>&1 &
|
||||
fi
|
||||
LAST_HASH="$CURRENT_HASH"
|
||||
sleep 2
|
||||
done
|
||||
) &
|
||||
WATCHER_PID=$!
|
||||
echo -e "${YELLOW}Using polling for file watching (install inotify-tools for better performance)${NC}"
|
||||
fi
|
||||
echo -e "${GREEN}Auto-reload enabled - editing .clj files will trigger reload${NC}"
|
||||
fi
|
||||
|
||||
# Start frontend
|
||||
echo -e "${GREEN}Starting frontend server...${NC}"
|
||||
@@ -93,7 +145,7 @@ echo -e "${GREEN}Backend:${NC} http://localhost:3000"
|
||||
echo -e "${GREEN}nREPL:${NC} localhost:$NREPL_PORT"
|
||||
echo -e "${GREEN}Frontend:${NC} https://localhost:5173"
|
||||
echo -e "${GREEN}Phone:${NC} https://${LOCAL_IP}:5173"
|
||||
echo -e "\n${YELLOW}Auto-reload is active. Edit any .clj file to trigger reload.${NC}"
|
||||
echo -e "\n${YELLOW}Edit any .clj file to trigger auto-reload.${NC}"
|
||||
echo -e "Press Ctrl+C to stop\n"
|
||||
|
||||
# Wait for processes
|
||||
|
||||
Reference in New Issue
Block a user