commit
Restart on new builds and rebuild after every pull
deploy/run now starts the app with deno run --watch=build/, and a post-merge hook in deploy/hooks installs dependencies and rebuilds after git pull. Enable the hook once with git config core.hooksPath deploy/hooks. Co-Authored-By: Sandrone <[email protected]>
diff --git a/README.md b/README.md
index 5414d6e..538e5d4 100644
--- a/README.md
+++ b/README.md
@@ -127,3 +127,16 @@ The server folder needs `build/`, `node_modules/`, `config/`, `package.json` and
It also needs a `data/` folder that `clove` can write to; the SQLite file lives there.
Set `ORIGIN` in the server's `.env` to the dashboard's public address.
+
+### Updating
+
+Run this once in `/srv/clove/isATracker`, so every `git pull` rebuilds the app:
+
+```sh
+git config core.hooksPath deploy/hooks
+```
+
+After that, `git pull` is the whole deploy. The hook installs dependencies and runs the build,
+and `deno run --watch` restarts the service when `build/` changes. The dashboard is down for
+the few seconds the build takes to write `build/`. A build that fails to compile leaves the old
+one running.
diff --git a/deploy/hooks/post-merge b/deploy/hooks/post-merge
new file mode 100755
index 0000000..17b79bc
--- /dev/null
+++ b/deploy/hooks/post-merge
@@ -0,0 +1,9 @@
+#!/bin/sh
+# deploy/hooks/post-merge
+# MIT — (c) Doughmination System®
+
+# Rebuild after a pull; deploy/run's --watch then restarts the service on the new build.
+# Enable once with: git config core.hooksPath deploy/hooks
+cd "$(git rev-parse --show-toplevel)" || exit 1
+
+deno install && deno task build
diff --git a/deploy/run b/deploy/run
index 167eaf9..67152a4 100755
--- a/deploy/run
+++ b/deploy/run
@@ -17,7 +17,9 @@ export HOME=/home/clove
# ORIGIN must be the dashboard's public URL: SvelteKit needs it for form actions (CSRF check)
# Reads are limited to this folder; writes are limited to data/, where the SQLite file lives
+# --watch restarts on a new build; deploy/hooks/post-merge rebuilds after every git pull
exec chpst -u clove /usr/bin/deno run \
+ --watch=build/ \
--allow-net \
--allow-env \
--allow-read=. \