Files
Tafa/Makefile
Philipp Ludewig de3ab5d2a6 Initial commit
App works locally. No intention to bring this live.
2026-04-23 16:35:12 -04:00

38 lines
1.3 KiB
Makefile

.PHONY: install dev start stop restart logs clean help
PID_FILE := .tafa.pid
LOG_FILE := .tafa.log
PORT := 8000
help: ## Show this help message
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage: make \033[36m<target>\033[0m\n\nTargets:\n"} \
/^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-12s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)
install: ## Install dependencies and set up the virtual environment
uv sync
dev: ## Start the server in the foreground with live-reload (for development)
uv run uvicorn main:app --reload --port $(PORT)
start: ## Start the server in the background (logs to .tafa.log)
@if [ -f $(PID_FILE) ] && kill -0 $$(cat $(PID_FILE)) 2>/dev/null; then \
echo "Already running (PID $$(cat $(PID_FILE)))"; \
else \
nohup .venv/bin/uvicorn main:app --port $(PORT) >> $(LOG_FILE) 2>&1 & \
echo $$! > $(PID_FILE); \
echo "Started on http://localhost:$(PORT) (PID $$(cat $(PID_FILE)))"; \
fi
restart: stop ## Restart the background server
kill: ## Kill any process holding port 8000 (use when Ctrl+C leaves a zombie)
@lsof -ti :$(PORT) | xargs -r kill -9 && echo "Killed" || echo "Nothing on port $(PORT)"
logs: ## Tail the background server log
@tail -f $(LOG_FILE)
clean: ## Remove venv, logs, PID file, and local staging directory
rm -f $(PID_FILE) $(LOG_FILE)
rm -rf .venv
rm -rf ~/.tafa/staging