generated from coulomb/repo-seed
fixed restart target
This commit is contained in:
20
Makefile
20
Makefile
@@ -2,6 +2,7 @@ PORT := 8002
|
||||
PIDFILE := var/api.pid
|
||||
LOGFILE := var/api-8002.log
|
||||
UVICORN := .venv/bin/uvicorn
|
||||
HEALTH_URL := http://127.0.0.1:$(PORT)/health
|
||||
|
||||
.DEFAULT_GOAL := help
|
||||
.PHONY: help start stop restart status showlogs
|
||||
@@ -15,10 +16,23 @@ start: ## Start the API server in the background on port 8002
|
||||
@if [ -f $(PIDFILE) ] && kill -0 $$(cat $(PIDFILE)) 2>/dev/null; then \
|
||||
echo "Already running (PID $$(cat $(PIDFILE)))"; \
|
||||
else \
|
||||
nohup $(UVICORN) repo_registry.web_api.app:app --port $(PORT) \
|
||||
setsid sh -c 'echo $$$$ > $(PIDFILE); exec $(UVICORN) repo_registry.web_api.app:app --host 127.0.0.1 --port $(PORT)' \
|
||||
>> $(LOGFILE) 2>&1 & \
|
||||
echo $$! > $(PIDFILE); \
|
||||
echo "Started (PID $$!) — http://127.0.0.1:$(PORT)/ui"; \
|
||||
PID=""; \
|
||||
for i in $$(seq 1 50); do \
|
||||
if [ -f $(PIDFILE) ]; then PID=$$(cat $(PIDFILE)); fi; \
|
||||
if [ -n "$$PID" ] && ! kill -0 $$PID 2>/dev/null; then break; fi; \
|
||||
if curl -fsS $(HEALTH_URL) >/dev/null 2>&1; then \
|
||||
echo "Started (PID $$PID) — http://127.0.0.1:$(PORT)/ui"; \
|
||||
exit 0; \
|
||||
fi; \
|
||||
sleep 0.1; \
|
||||
done; \
|
||||
rm -f $(PIDFILE); \
|
||||
echo "Failed to start API server on http://127.0.0.1:$(PORT)/ui"; \
|
||||
echo "Recent log output:"; \
|
||||
tail -40 $(LOGFILE) 2>/dev/null || true; \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
stop: ## Stop the API server
|
||||
|
||||
Reference in New Issue
Block a user