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

18
config/config.exs Normal file
View File

@@ -0,0 +1,18 @@
import Config
# Default configuration values
# These are overridden by config/runtime.exs in releases
config :org_garden,
zotero_url: "http://localhost:23119",
citation_mode: :warn,
http_port: 8080,
ws_port: 3001,
health_port: 9090
config :logger, :console,
format: "$time $metadata[$level] $message\n",
metadata: [:module]
# Import environment specific config
import_config "#{config_env()}.exs"

4
config/dev.exs Normal file
View File

@@ -0,0 +1,4 @@
import Config
# Development-specific configuration
config :logger, level: :debug

6
config/prod.exs Normal file
View File

@@ -0,0 +1,6 @@
import Config
# Production-specific configuration
# Most config comes from runtime.exs via environment variables
config :logger, level: :info

42
config/runtime.exs Normal file
View File

@@ -0,0 +1,42 @@
import Config
# Runtime configuration from environment variables
# This file is executed at runtime (not compile time)
defmodule RuntimeConfig do
def parse_int(nil, default), do: default
def parse_int(val, _default) when is_integer(val), do: val
def parse_int(val, default) when is_binary(val) do
case Integer.parse(val) do
{int, ""} -> int
_ -> default
end
end
def parse_citation_mode("silent"), do: :silent
def parse_citation_mode("strict"), do: :strict
def parse_citation_mode(_), do: :warn
end
# Core paths
if quartz_path = System.get_env("QUARTZ_PATH") do
config :org_garden, quartz_path: quartz_path
end
config :org_garden,
node_path: System.get_env("NODE_PATH", "node"),
notes_dir: System.get_env("NOTES_DIR"),
output_dir: System.get_env("OUTPUT_DIR")
# Citation configuration
config :org_garden,
zotero_url: System.get_env("ZOTERO_URL", "http://localhost:23119"),
bibtex_file: System.get_env("BIBTEX_FILE"),
citation_mode: RuntimeConfig.parse_citation_mode(System.get_env("CITATION_MODE"))
# Server ports
config :org_garden,
http_port: RuntimeConfig.parse_int(System.get_env("PORT"), 8080),
ws_port: RuntimeConfig.parse_int(System.get_env("WS_PORT"), 3001),
health_port: RuntimeConfig.parse_int(System.get_env("HEALTH_PORT"), 9090)

4
config/test.exs Normal file
View File

@@ -0,0 +1,4 @@
import Config
# Test-specific configuration
config :logger, level: :warning