Add service infrastructure for long-running deployment

- Add configuration system (config/*.exs, OrgGarden.Config)
- Refactor supervision tree with DynamicSupervisor and Registry
- Add OrgGarden.Server for serve mode lifecycle management
- Add health check HTTP endpoints (Bandit/Plug on :9090)
- Add telemetry events for export and watcher operations
- Implement graceful shutdown with SIGTERM handling
- Add Mix Release support with overlay scripts
- Add NixOS module for systemd service deployment
- Update documentation with service usage
This commit is contained in:
Ignacio Ballesteros
2026-02-21 20:38:47 +01:00
parent 6476b45f04
commit 01805dbf39
23 changed files with 1147 additions and 83 deletions

16
rel/env.sh.eex Normal file
View File

@@ -0,0 +1,16 @@
#!/bin/sh
# Release environment configuration
# This file is evaluated before the release starts
# Disable Erlang distribution (not needed for this application)
export RELEASE_DISTRIBUTION=none
# Enable shell history in IEx
export ERL_AFLAGS="-kernel shell_history enabled"
# Set release node name
export RELEASE_NODE=org_garden
# Log to console by default
export ELIXIR_ERL_OPTIONS="-noshell"

74
rel/overlays/bin/org-garden Executable file
View File

@@ -0,0 +1,74 @@
#!/bin/sh
set -e
# org-garden CLI wrapper
# Routes commands to the appropriate release entry point
SELF=$(readlink -f "$0" 2>/dev/null || realpath "$0" 2>/dev/null || echo "$0")
RELEASE_ROOT=$(cd "$(dirname "$SELF")/.." && pwd)
usage() {
cat <<EOF
Usage: org-garden <command> [options]
Commands:
serve <notes-dir> Start development server (long-running)
build <notes-dir> Build static site (one-shot)
export <notes-dir> Export org to markdown (one-shot)
Release commands:
daemon Start as background daemon
daemon_iex Start daemon with IEx attached
stop Stop running daemon
restart Restart running daemon
remote Connect to running instance
pid Print PID of running instance
version Print release version
Options:
--port <n> HTTP server port (default: 8080)
--ws-port <n> WebSocket port (default: 3001)
--output <path> Output directory
--watch Watch mode for export command
Environment:
NOTES_DIR Default notes directory
OUTPUT_DIR Default output directory
QUARTZ_PATH Path to Quartz installation
ZOTERO_URL Zotero Better BibTeX URL
BIBTEX_FILE Fallback BibTeX file
CITATION_MODE silent | warn | strict
EOF
}
case "${1:-}" in
serve)
shift
exec "$RELEASE_ROOT/bin/org_garden" start -- "$@"
;;
build)
shift
exec "$RELEASE_ROOT/bin/org_garden" eval "OrgGarden.CLI.main([\"build\" | System.argv()])" -- "$@"
;;
export)
shift
exec "$RELEASE_ROOT/bin/org_garden" eval "OrgGarden.CLI.main([\"export\" | System.argv()])" -- "$@"
;;
daemon|daemon_iex|stop|restart|remote|pid|version|start|start_iex|eval|rpc)
exec "$RELEASE_ROOT/bin/org_garden" "$@"
;;
-h|--help|help)
usage
exit 0
;;
"")
usage
exit 1
;;
*)
echo "Unknown command: $1" >&2
echo "" >&2
usage >&2
exit 1
;;
esac