ontoref-outreach/site/run.sh
2026-07-17 01:06:37 +01:00

52 lines
3.3 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "$SCRIPT_DIR"
lsof -ti:3030 | xargs kill -9 2>/dev/null || true
# Secrets (SMTP creds, CRYPTO_KEY, …) are provided as ENV by the deploy/provisioning
# layer (SOPS-decrypted at run time — e.g. `sops exec-env`), not from a plaintext
# file here. email.ncl reads ${SMTP_*}/${EMAIL_FROM} from that injected env.
# Only export what the server genuinely needs from here. SITE_CONFIG_PATH, NICKEL_IMPORT_PATH,
# HTMX_ASSETS_PATH and SITE_SERVER_CONTENT_ROOT are NOT set here on purpose: the `just local-install`
# wrapper at ~/.local/bin/rustelo-htmx-server resolves the site root from $PWD and sets all four
# (each with `: "${VAR:=…}"`, so anything exported here still wins). Setting them here too would
# duplicate that knowledge in a second place, and the two would drift.
export DATABASE_URL="${DATABASE_URL:-sqlite:data/dev.db}"
# Templates from the local runtime tree so .j2 edits need no cargo rebuild.
export HTMX_TEMPLATE_PATH="${HTMX_TEMPLATE_PATH:-htmx-templates}"
# Routes THIS site owns, merged over the ones embedded in the shared image. The last piece of a
# page that was not yet the consumer's: templates, Fluent and content already were. A route
# declared in the image is served by every site built from it — and needs an image rebuild per
# addition, because routes are embedded at build time. Declared here, a route costs no build.
#
# Requires rustelo_core_lib with `merge_site_routes` (a site route's component must end in `Page`;
# anything else names a compiled component a consumer cannot add, and is refused at startup).
# Unset ⇒ nothing changes, so this is safe to carry before the binary has the capability.
export RUSTELO_SITE_ROUTES="${RUSTELO_SITE_ROUTES:-site/config/routes}"
# Canonical public origin — feeds SEO canonical/OG URLs (seo::site_base_url).
# Without it the head falls back to http://127.0.0.1:3030.
export SITE_BASE_URL="${SITE_BASE_URL:-https://ontoref.dev}"
export SITE_NAME="${SITE_NAME:-ontoref}"
# Logo is config-driven: site/config/site.ncl [logo]. No env needed.
# ── Email delivery (post comments + contact form) ──────────────────────────
# Owner inbox for new post comments and contact-form submissions. Change to your
# real address. Delivery also needs email.enabled=true in site/config/email.ncl
# (provider=console logs to stdout in dev; set provider=smtp + creds for real send).
export POST_MESSAGE_RECIPIENT="${POST_MESSAGE_RECIPIENT:-jpl@jesusperez.pro}"
export CONTACT_RECIPIENT="${CONTACT_RECIPIENT:-$POST_MESSAGE_RECIPIENT}"
export EMAIL_FROM="${EMAIL_FROM:-noreply@ontoref.dev}"
export EMAIL_FROM_NAME="${EMAIL_FROM_NAME:-$SITE_NAME}"
# Quiet noisy framework tracing (these are informational logs the framework emits at
# WARN, not real problems): per-request routing conversions (🔄/🔍/✅), the category
# filter-index fallback ("using empty meta config"), NATS-not-configured, and the
# missing rustelo/migrations dir. Genuine warnings/errors (incl. RBAC audit) still show.
# Override by exporting RUST_LOG yourself before running.
export RUST_LOG="${RUST_LOG:-warn,rustelo_core_lib::routing=error,rustelo_core_lib::categories::cache=error,rustelo_server::nats=error,rustelo_server::migrations=error}"
exec rustelo-htmx-server