Skip to content

Commit b14394b

Browse files
committed
Changes to makefile and launcher for convenient self hosting
1 parent c90372c commit b14394b

File tree

3 files changed

+46
-18
lines changed

3 files changed

+46
-18
lines changed

.devcontainer/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ WORKDIR := /$(REPONAME)-$(REALHOSTNAME)
5757

5858
ifeq ($(SUPERREPO),1)
5959
# Temporary hack to mount the larger workspace:
60-
MOUNTDIR := `pwd`/../..
60+
MOUNTDIR := $(shell pwd)/../..
6161
REPOROOT := $(MOUNTDIR)/happy-fork
6262
else
63-
MOUNTDIR := `pwd`/..
63+
MOUNTDIR := $(shell pwd)/..
6464
REPOROOT := $(MOUNTDIR)
6565
endif
6666

@@ -116,15 +116,15 @@ web:
116116
-v `pwd`/home:/root \
117117
-v $(MOUNTDIR):$(WORKDIR) \
118118
$(PORTS_WEB) $(FULLTAG) \
119-
bash -c "cd $(REPOROOT) && ./happy-launcher.sh start-webapp"
119+
bash -c "cd $(WORKDIR) && make install-webapp && ./happy-launcher.sh start-webapp && ./happy-launcher.sh monitor"
120120

121121
# Happy server only (port 3005) - starts the server directly
122122
server:
123123
$(CONTAINER) run -it --rm -u root --hostname $(CONTAINER_HOSTNAME) \
124124
-v `pwd`/home:/root \
125125
-v $(MOUNTDIR):$(WORKDIR) \
126126
$(PORTS_SERVER) $(FULLTAG) \
127-
bash -c "cd $(REPOROOT) && ./happy-launcher.sh start-backend && tail -f /dev/null"
127+
bash -c "cd $(WORKDIR) && make install-server && ./happy-launcher.sh start-backend && ./happy-launcher.sh monitor"
128128

129129
AGENT_LAYERS = Dockerfile.claude Dockerfile.copilot
130130
# Dockerfile.gemini

Makefile

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help setup rebase-upstream status feature-start feature-end build build-cli build-server install server stop logs cli e2e-test browser-inspect setup-credentials validate validate-quick push
1+
.PHONY: help setup rebase-upstream status feature-start feature-end build build-cli build-server install install-server install-cli install-webapp server stop logs cli e2e-test browser-inspect setup-credentials validate validate-quick push
22

33
# Base development branch for submodules (combines all features we want to merge)
44
BASE_SUBMODULE_BRANCH := rrnewton
@@ -19,6 +19,9 @@ help:
1919
@echo " make build-cli - Build happy-cli only"
2020
@echo " make build-server - Typecheck happy-server only"
2121
@echo " make install - Install dependencies for all repos"
22+
@echo " make install-server - Install happy-server dependencies only"
23+
@echo " make install-cli - Install happy-cli dependencies only"
24+
@echo " make install-webapp - Install happy webapp dependencies only"
2225
@echo ""
2326
@echo "=== Testing ==="
2427
@echo " make validate - Run all validation tests (builds + unit + browser)"
@@ -183,18 +186,23 @@ feature-end:
183186
# Build Targets
184187
# ============================================================================
185188

186-
# Install dependencies for all repositories
187-
install:
188-
@echo "=== Installing dependencies for all repositories ==="
189-
@echo ""
189+
# Install dependencies for happy-server
190+
install-server:
190191
@echo "Installing happy-server dependencies..."
191192
@cd happy-server && yarn install
192-
@echo ""
193+
194+
# Install dependencies for happy-cli
195+
install-cli:
193196
@echo "Installing happy-cli dependencies..."
194197
@cd happy-cli && yarn install
195-
@echo ""
198+
199+
# Install dependencies for happy webapp
200+
install-webapp:
196201
@echo "Installing happy webapp dependencies..."
197202
@cd happy && yarn install
203+
204+
# Install dependencies for all repositories
205+
install: install-server install-cli install-webapp
198206
@echo ""
199207
@echo "=== All dependencies installed ==="
200208

happy-launcher.sh

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ info() { echo -e "${BLUE}[INFO]${NC} $1"; }
216216
success() { echo -e "${GREEN}[SUCCESS]${NC} $1"; }
217217
warning() { echo -e "${YELLOW}[WARNING]${NC} $1"; }
218218
error() { echo -e "${RED}[ERROR]${NC} $1"; }
219+
notfound() { echo -e "${YELLOW}[NOTFOUND]${NC} $1"; }
219220

220221
# Check if a service is running (system-wide, slot-unaware)
221222
is_running() {
@@ -724,7 +725,7 @@ show_slot_services_status() {
724725
elif port_listening "$minio_port"; then
725726
success " MinIO: Running (API: $minio_port, Console: $minio_console_port)"
726727
else
727-
error " MinIO: Stopped"
728+
notfound " MinIO: Stopped"
728729
fi
729730

730731
# happy-server (slot-specific)
@@ -737,7 +738,7 @@ show_slot_services_status() {
737738
elif port_listening "$server_port"; then
738739
success " happy-server: Running (port $server_port)"
739740
else
740-
error " happy-server: Stopped"
741+
notfound " happy-server: Stopped"
741742
fi
742743

743744
# Webapp (slot-specific)
@@ -750,7 +751,7 @@ show_slot_services_status() {
750751
elif port_listening "$webapp_port"; then
751752
success " Webapp: Running (port $webapp_port)"
752753
else
753-
error " Webapp: Stopped"
754+
notfound " Webapp: Stopped"
754755
fi
755756
}
756757

@@ -783,13 +784,13 @@ show_status() {
783784
if port_listening "$POSTGRES_PORT"; then
784785
success "PostgreSQL: Running (port $POSTGRES_PORT, database: $DATABASE_NAME)"
785786
else
786-
error "PostgreSQL: Stopped"
787+
notfound "PostgreSQL: Stopped"
787788
fi
788789

789790
if port_listening "$REDIS_PORT"; then
790791
success "Redis: Running (port $REDIS_PORT, shared)"
791792
else
792-
error "Redis: Stopped"
793+
notfound "Redis: Stopped"
793794
fi
794795

795796
# Slot-specific services
@@ -809,13 +810,13 @@ show_all_slots_status() {
809810
if port_listening "$POSTGRES_PORT"; then
810811
success "PostgreSQL: Running (port $POSTGRES_PORT)"
811812
else
812-
error "PostgreSQL: Stopped"
813+
notfound "PostgreSQL: Stopped"
813814
fi
814815

815816
if port_listening "$REDIS_PORT"; then
816817
success "Redis: Running (port $REDIS_PORT)"
817818
else
818-
error "Redis: Stopped"
819+
notfound "Redis: Stopped"
819820
fi
820821
echo ""
821822

@@ -1031,6 +1032,24 @@ case "${1:-}" in
10311032
show_urls
10321033
;;
10331034

1035+
monitor)
1036+
# Monitor mode: show status periodically, handle signals gracefully
1037+
info "Monitoring services (Ctrl-C to stop)..."
1038+
echo ""
1039+
1040+
# Trap signals for graceful exit
1041+
trap 'echo ""; info "Monitor stopped"; exit 0' SIGINT SIGTERM
1042+
1043+
while true; do
1044+
echo ""
1045+
echo "=== Happy Monitor ($(date '+%H:%M:%S')) - Ctrl-C to stop ==="
1046+
echo ""
1047+
show_status
1048+
sleep 60 &
1049+
wait $! # Wait on sleep so signals can interrupt it
1050+
done
1051+
;;
1052+
10341053
env)
10351054
print_env
10361055
;;
@@ -1068,6 +1087,7 @@ case "${1:-}" in
10681087
echo " status Show status of all services"
10691088
echo " status --all-slots Show status for all active slots"
10701089
echo " logs <service> Tail logs for a service (server, webapp, minio, postgres)"
1090+
echo " monitor Show status every 60 seconds (handles Ctrl-C gracefully)"
10711091
echo " env Print environment variables for this slot (can be sourced)"
10721092
echo " cli [args] Run happy CLI with local server configuration"
10731093
echo " test Test server and CLI connectivity"

0 commit comments

Comments
 (0)