This commit is contained in:
91
Makefile
91
Makefile
@@ -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
|
VENV := .venv
|
||||||
PY := $(VENV)/bin/python
|
PY := $(VENV)/bin/python
|
||||||
@@ -7,11 +7,13 @@ PERM_DIR := /home/zaine/master-folder/projects/scripts/bash-scripts
|
|||||||
|
|
||||||
AUTHOR_PORT := 8765
|
AUTHOR_PORT := 8765
|
||||||
AUTHOR_URL := http://127.0.0.1:$(AUTHOR_PORT)
|
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_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:
|
build:
|
||||||
@echo "Building project..."
|
@echo "Building project..."
|
||||||
@@ -42,41 +44,37 @@ norm:
|
|||||||
@echo "sorting out the backups..."
|
@echo "sorting out the backups..."
|
||||||
find . -path ./backups -prune -o -type f -name '*~' -exec mv {} backups/ \;
|
find . -path ./backups -prune -o -type f -name '*~' -exec mv {} backups/ \;
|
||||||
|
|
||||||
author: $(VENV)
|
author: author-start
|
||||||
@echo "Starting local authoring UI in foreground..."
|
|
||||||
$(PY) authoring_server.py
|
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:
|
author-stop:
|
||||||
@echo "Stopping existing authoring UI if running..."
|
@echo "Stopping authoring UI with systemd..."
|
||||||
@mkdir -p /home/zaine/logs
|
systemctl --user stop "$(AUTHOR_SERVICE)" || true
|
||||||
@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
|
|
||||||
|
|
||||||
author-restart: $(VENV) author-stop
|
author-restart: author-install
|
||||||
@echo "Starting authoring UI on port $(AUTHOR_PORT)..."
|
@echo "Restarting authoring UI with systemd..."
|
||||||
@mkdir -p /home/zaine/logs
|
systemctl --user restart "$(AUTHOR_SERVICE)"
|
||||||
@cd "$(CURDIR)" && nohup "$(CURDIR)/$(PY)" -u authoring_server.py > "$(AUTHOR_LOG)" 2>&1 & echo $$! > "$(AUTHOR_PID)"
|
@$(MAKE) --no-print-directory author-health
|
||||||
|
|
||||||
|
author-health:
|
||||||
@echo "Waiting for authoring UI and page list to respond..."
|
@echo "Waiting for authoring UI and page list to respond..."
|
||||||
@for i in 1 2 3 4 5 6 7 8 9 10; do \
|
@for i in 1 2 3 4 5 6 7 8 9 10; do \
|
||||||
PID=$$(cat "$(AUTHOR_PID)"); \
|
if ! systemctl --user is-active --quiet "$(AUTHOR_SERVICE)"; then \
|
||||||
if ! kill -0 $$PID 2>/dev/null; then \
|
echo "Authoring UI service is not active. Service status:"; \
|
||||||
echo "Authoring UI process exited before becoming healthy. Last logs:"; \
|
systemctl --user status --no-pager "$(AUTHOR_SERVICE)" || true; \
|
||||||
tail -n 80 "$(AUTHOR_LOG)" || true; \
|
echo "Recent logs:"; \
|
||||||
|
journalctl --user -u "$(AUTHOR_SERVICE)" -n 80 --no-pager || true; \
|
||||||
exit 1; \
|
exit 1; \
|
||||||
fi; \
|
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 \
|
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; \
|
fi; \
|
||||||
sleep 1; \
|
sleep 1; \
|
||||||
done; \
|
done; \
|
||||||
echo "Authoring UI failed to start. Last logs:"; \
|
echo "Authoring UI failed to respond. Service status:"; \
|
||||||
tail -n 80 "$(AUTHOR_LOG)" || true; \
|
systemctl --user status --no-pager "$(AUTHOR_SERVICE)" || true; \
|
||||||
|
echo "Recent logs:"; \
|
||||||
|
journalctl --user -u "$(AUTHOR_SERVICE)" -n 80 --no-pager || true; \
|
||||||
exit 1
|
exit 1
|
||||||
|
|
||||||
author-status:
|
author-status:
|
||||||
@if [ -f "$(AUTHOR_PID)" ] && kill -0 $$(cat "$(AUTHOR_PID)") 2>/dev/null; then \
|
@systemctl --user status --no-pager "$(AUTHOR_SERVICE)" || true
|
||||||
echo "PID: $$(cat "$(AUTHOR_PID)")"; \
|
|
||||||
else \
|
|
||||||
echo "No live authoring UI PID recorded."; \
|
|
||||||
fi
|
|
||||||
@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
|
@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:
|
help:
|
||||||
@echo "Available targets:"
|
@echo "Available targets:"
|
||||||
@echo " make - Full rebuild and restart authoring UI"
|
@echo " make - Full rebuild and restart authoring UI"
|
||||||
@@ -105,9 +104,11 @@ help:
|
|||||||
@echo " make clean-output - Remove output directory"
|
@echo " make clean-output - Remove output directory"
|
||||||
@echo " make clean-venv - Remove venv directory"
|
@echo " make clean-venv - Remove venv directory"
|
||||||
@echo " make norm - Move backup files"
|
@echo " make norm - Move backup files"
|
||||||
@echo " make author - Start the local authoring UI in foreground"
|
@echo " make author - Install and start the authoring UI service"
|
||||||
@echo " make author-stop - Stop the authoring UI"
|
@echo " make author-install - Install and enable the authoring UI service"
|
||||||
@echo " make author-restart - Restart the authoring UI in background"
|
@echo " make author-stop - Stop the authoring UI service"
|
||||||
@echo " make author-status - Show authoring UI PID and page count"
|
@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 search - Create the search index"
|
||||||
@echo " make help - Show this help message"
|
@echo " make help - Show this help message"
|
||||||
|
|||||||
@@ -6,7 +6,14 @@ The site is written using Emacs and Org-mode, and exported using the `org-publis
|
|||||||
|
|
||||||
## Local authoring UI
|
## Local authoring UI
|
||||||
|
|
||||||
Run `make author` and open `http://127.0.0.1:8765` to create or edit blog and post Org files from a browser. When deployed behind the reverse proxy, use `https://author.zainezq.com`.
|
Run `make author` to install and start the user systemd service, then open `http://127.0.0.1:8765` to create or edit blog and post Org files from a browser. When deployed behind the reverse proxy, use `https://author.zainezq.com`.
|
||||||
|
|
||||||
|
The service unit is checked in at `systemd/user/org-web-authoring.service` and is installed to `~/.config/systemd/user/` by the Makefile. Useful service commands:
|
||||||
|
|
||||||
|
- `make author-restart` restarts the service and waits for the page API to respond
|
||||||
|
- `make author-stop` stops the service
|
||||||
|
- `make author-status` shows systemd status and the editable page count
|
||||||
|
- `make author-logs` shows recent journal logs
|
||||||
|
|
||||||
The editor writes normal `.org` pages with the metadata used by the publishing pipeline:
|
The editor writes normal `.org` pages with the metadata used by the publishing pipeline:
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
See the categories: @@html:<a href="../home/categories.html">Categories</a>@@
|
See the categories: @@html:<a href="../home/categories.html">Categories</a>@@
|
||||||
|
|
||||||
* Posts:
|
* Posts:
|
||||||
- [[file:career/career-list.org][Career List]] @@html:<span class="post-date">07-05-2026 16:45</span>@@
|
- [[file:career/career-list.org][Career List]] @@html:<span class="post-date">07-05-2026 23:40</span>@@
|
||||||
- [[file:posts-list.sync-conflict-20260417-233432-VT6366A.org][Posts List]] @@html:<span class="post-date">14-04-2026 16:36</span>@@
|
- [[file:posts-list.sync-conflict-20260417-233432-VT6366A.org][Posts List]] @@html:<span class="post-date">14-04-2026 16:36</span>@@
|
||||||
- [[file:career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] @@html:<span class="post-date">11-03-2026 17:18</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@
|
- [[file:career/ha-dr.org][High Availability, Disaster Recovery and Business Continuity]] @@html:<span class="post-date">11-03-2026 17:18</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@
|
||||||
- [[file:career/javascript.org][Understands the Javascript language]] @@html:<span class="post-date">11-03-2026 16:52</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@
|
- [[file:career/javascript.org][Understands the Javascript language]] @@html:<span class="post-date">11-03-2026 16:52</span>@@ @@html:<a href="/tags/learning.html"><span class="post-tag">learning</span></a>@@ @@html:<a href="/tags/notes.html"><span class="post-tag">notes</span></a>@@
|
||||||
|
|||||||
@@ -12,9 +12,9 @@
|
|||||||
- [[file:tags/review.org][Tag: review]]
|
- [[file:tags/review.org][Tag: review]]
|
||||||
- [[file:tags/website.org][Tag: website]]
|
- [[file:tags/website.org][Tag: website]]
|
||||||
- [[file:tags/update.org][Tag: update]]
|
- [[file:tags/update.org][Tag: update]]
|
||||||
|
- [[file:tags/insights.org][Tag: insights]]
|
||||||
- [[file:tags/life.org][Tag: life]]
|
- [[file:tags/life.org][Tag: life]]
|
||||||
- [[file:tags/education.org][Tag: education]]
|
- [[file:tags/education.org][Tag: education]]
|
||||||
- [[file:tags/insights.org][Tag: insights]]
|
|
||||||
- [[file:tags/reading.org][Tag: reading]]
|
- [[file:tags/reading.org][Tag: reading]]
|
||||||
- [[file:tags/emacs.org][Tag: emacs]]
|
- [[file:tags/emacs.org][Tag: emacs]]
|
||||||
- [[file:tags/maths.org][Tag: maths]]
|
- [[file:tags/maths.org][Tag: maths]]
|
||||||
|
|||||||
16
systemd/user/org-web-authoring.service
Normal file
16
systemd/user/org-web-authoring.service
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Org web authoring UI
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
WorkingDirectory=/home/zaine/master-folder/org_files/org_web
|
||||||
|
Environment=AUTHOR_ROOT=/home/zaine/master-folder/org_files/org_web
|
||||||
|
Environment=AUTHOR_PORT=8765
|
||||||
|
Environment=PYTHONUNBUFFERED=1
|
||||||
|
ExecStart=/home/zaine/master-folder/org_files/org_web/.venv/bin/python -u /home/zaine/master-folder/org_files/org_web/authoring_server.py
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=5
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
Reference in New Issue
Block a user