cha
Some checks failed
Build Org Website / build (push) Failing after 52s

This commit is contained in:
2026-05-07 23:40:40 +01:00
parent 8262a076de
commit 6af4cb1d23
5 changed files with 72 additions and 48 deletions

View File

@@ -1,4 +1,4 @@
.PHONY: all clean norm author author-stop author-restart author-status help
.PHONY: all clean norm author author-install author-start author-stop author-restart author-status author-logs author-health help
VENV := .venv
PY := $(VENV)/bin/python
@@ -7,11 +7,13 @@ PERM_DIR := /home/zaine/master-folder/projects/scripts/bash-scripts
AUTHOR_PORT := 8765
AUTHOR_URL := http://127.0.0.1:$(AUTHOR_PORT)
AUTHOR_PID := /home/zaine/logs/authoring-server.pid
AUTHOR_LOG := /home/zaine/logs/authoring-server.log
AUTHOR_PAGES_CHECK := /tmp/authoring-server-pages.json
AUTHOR_SERVICE := org-web-authoring.service
AUTHOR_UNIT_SRC := systemd/user/$(AUTHOR_SERVICE)
SYSTEMD_USER_DIR := $(HOME)/.config/systemd/user
AUTHOR_UNIT_DST := $(SYSTEMD_USER_DIR)/$(AUTHOR_SERVICE)
all: set-perms clean-output build search author-restart clean-venv
all: set-perms clean-output build search author-restart
build:
@echo "Building project..."
@@ -42,41 +44,37 @@ norm:
@echo "sorting out the backups..."
find . -path ./backups -prune -o -type f -name '*~' -exec mv {} backups/ \;
author: $(VENV)
@echo "Starting local authoring UI in foreground..."
$(PY) authoring_server.py
author: author-start
author-install: $(VENV)
@echo "Installing $(AUTHOR_SERVICE) for the current user..."
@mkdir -p "$(SYSTEMD_USER_DIR)"
install -m 0644 "$(AUTHOR_UNIT_SRC)" "$(AUTHOR_UNIT_DST)"
systemctl --user daemon-reload
systemctl --user enable "$(AUTHOR_SERVICE)"
author-start: author-install
@echo "Starting authoring UI with systemd..."
systemctl --user start "$(AUTHOR_SERVICE)"
@$(MAKE) --no-print-directory author-health
author-stop:
@echo "Stopping existing authoring UI if running..."
@mkdir -p /home/zaine/logs
@if [ -f "$(AUTHOR_PID)" ]; then \
PID=$$(cat "$(AUTHOR_PID)"); \
if kill -0 $$PID 2>/dev/null; then \
echo "Stopping PID $$PID"; \
kill $$PID 2>/dev/null || true; \
for i in 1 2 3 4 5; do \
if ! kill -0 $$PID 2>/dev/null; then break; fi; \
sleep 1; \
done; \
if kill -0 $$PID 2>/dev/null; then \
echo "PID $$PID did not stop cleanly; killing it."; \
kill -9 $$PID 2>/dev/null || true; \
fi; \
fi; \
rm -f "$(AUTHOR_PID)"; \
fi
@fuser -k $(AUTHOR_PORT)/tcp >/dev/null 2>&1 || true
@echo "Stopping authoring UI with systemd..."
systemctl --user stop "$(AUTHOR_SERVICE)" || true
author-restart: $(VENV) author-stop
@echo "Starting authoring UI on port $(AUTHOR_PORT)..."
@mkdir -p /home/zaine/logs
@cd "$(CURDIR)" && nohup "$(CURDIR)/$(PY)" -u authoring_server.py > "$(AUTHOR_LOG)" 2>&1 & echo $$! > "$(AUTHOR_PID)"
author-restart: author-install
@echo "Restarting authoring UI with systemd..."
systemctl --user restart "$(AUTHOR_SERVICE)"
@$(MAKE) --no-print-directory author-health
author-health:
@echo "Waiting for authoring UI and page list to respond..."
@for i in 1 2 3 4 5 6 7 8 9 10; do \
PID=$$(cat "$(AUTHOR_PID)"); \
if ! kill -0 $$PID 2>/dev/null; then \
echo "Authoring UI process exited before becoming healthy. Last logs:"; \
tail -n 80 "$(AUTHOR_LOG)" || true; \
if ! systemctl --user is-active --quiet "$(AUTHOR_SERVICE)"; then \
echo "Authoring UI service is not active. Service status:"; \
systemctl --user status --no-pager "$(AUTHOR_SERVICE)" || true; \
echo "Recent logs:"; \
journalctl --user -u "$(AUTHOR_SERVICE)" -n 80 --no-pager || true; \
exit 1; \
fi; \
if curl -fsS "$(AUTHOR_URL)/api/pages" -o "$(AUTHOR_PAGES_CHECK)" && $(PY) -c 'import json,sys; data=json.load(sys.stdin); sys.exit(0 if isinstance(data, list) and data else 1)' < "$(AUTHOR_PAGES_CHECK)"; then \
@@ -85,18 +83,19 @@ author-restart: $(VENV) author-stop
fi; \
sleep 1; \
done; \
echo "Authoring UI failed to start. Last logs:"; \
tail -n 80 "$(AUTHOR_LOG)" || true; \
echo "Authoring UI failed to respond. Service status:"; \
systemctl --user status --no-pager "$(AUTHOR_SERVICE)" || true; \
echo "Recent logs:"; \
journalctl --user -u "$(AUTHOR_SERVICE)" -n 80 --no-pager || true; \
exit 1
author-status:
@if [ -f "$(AUTHOR_PID)" ] && kill -0 $$(cat "$(AUTHOR_PID)") 2>/dev/null; then \
echo "PID: $$(cat "$(AUTHOR_PID)")"; \
else \
echo "No live authoring UI PID recorded."; \
fi
@systemctl --user status --no-pager "$(AUTHOR_SERVICE)" || true
@curl -fsS "$(AUTHOR_URL)/api/pages" -o "$(AUTHOR_PAGES_CHECK)" && $(PY) -c 'import json,sys; print(f"Pages: {len(json.load(sys.stdin))}")' < "$(AUTHOR_PAGES_CHECK)" || true
author-logs:
journalctl --user -u "$(AUTHOR_SERVICE)" -n 100 --no-pager
help:
@echo "Available targets:"
@echo " make - Full rebuild and restart authoring UI"
@@ -105,9 +104,11 @@ help:
@echo " make clean-output - Remove output directory"
@echo " make clean-venv - Remove venv directory"
@echo " make norm - Move backup files"
@echo " make author - Start the local authoring UI in foreground"
@echo " make author-stop - Stop the authoring UI"
@echo " make author-restart - Restart the authoring UI in background"
@echo " make author-status - Show authoring UI PID and page count"
@echo " make author - Install and start the authoring UI service"
@echo " make author-install - Install and enable the authoring UI service"
@echo " make author-stop - Stop the authoring UI service"
@echo " make author-restart - Restart the authoring UI service"
@echo " make author-status - Show authoring UI service status and page count"
@echo " make author-logs - Show recent authoring UI service logs"
@echo " make search - Create the search index"
@echo " make help - Show this help message"