summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2025-12-01 20:08:34 -0300
committerEuAndreh <eu@euandre.org>2025-12-01 20:08:34 -0300
commit6c1930eadbdfec8b825f1aadc2304a5017a03551 (patch)
treedbd67653f8a75188796f4d7edaad52837e0bc63d /bin
parentm (diff)
downloaddatomic-6c1930eadbdfec8b825f1aadc2304a5017a03551.tar.gz
datomic-6c1930eadbdfec8b825f1aadc2304a5017a03551.tar.xz
m
Diffstat (limited to 'bin')
-rwxr-xr-xbin/transactor19
-rwxr-xr-xbin/transactor.in79
2 files changed, 79 insertions, 19 deletions
diff --git a/bin/transactor b/bin/transactor
deleted file mode 100755
index 54c7b0d..0000000
--- a/bin/transactor
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/bin/sh
-set -euo pipefail
-
-sqlite3 storage.db < etc/init.sql
-mkdir -p tmp cache
-
-exec java \
- -server \
- -Djava.security.manager=allow \
- -Ddatomic.valcachePath=cache2 \
- -Ddatomic.valcacheMaxGb=100 \
- -Xms4g \
- -Xmx4g \
- -XX:+UseG1GC \
- -XX:MaxGCPauseMillis=50 \
- --class-path 'etc/:lib/*' \
- clojure.main \
- --main datomic.launcher \
- etc/transactor.properties
diff --git a/bin/transactor.in b/bin/transactor.in
new file mode 100755
index 0000000..c47f2c7
--- /dev/null
+++ b/bin/transactor.in
@@ -0,0 +1,79 @@
+#!/bin/sh
+set -euo pipefail
+
+
+usage() {
+ cat <<-'EOF'
+ Usage:
+ transactor [-p PORT] FILE
+ EOF
+}
+
+
+
+VALCACHESIZE=
+PORT=50200
+CACHEDIR='cache'
+TEMPDATADIR='tmp'
+while getopts 'p:C:S:T:' flag; do
+ case "$flag" in
+ (p)
+ PORT="$OPTARG"
+ ;;
+ (C)
+ CACHEDIR="$OPTARG"
+ ;;
+ (S)
+ VALCACHESIZE="$OPTARG"
+ ;;
+ (T)
+ TEMPDATADIR="$OPTARG"
+ ;;
+ (*)
+ usage >&2
+ exit 2
+ ;;
+ esac
+done
+shift $((OPTIND - 1))
+
+if [ -z "${1:-}" ]; then
+ echo 'Missing FILE.' >&2
+ usage >&2
+ exit 2
+fi
+FILE="$1"
+
+
+
+if [ -z "$VALCACHESIZE" ]; then
+ VALCACHESIZE="$(
+ df -Pk "$FILE" |
+ tail -n1 |
+ awk '{printf "%.0f\n", $2 / (1024 * 1024)}'
+ )"
+fi
+
+sqlite3 "$FILE" < @SYSCONFDIR@/init.sql >&2
+
+set -x
+exec java \
+ -server \
+ -Djava.security.manager=allow \
+ -Xms4g \
+ -Xmx4g \
+ -XX:+UseG1GC \
+ -XX:MaxGCPauseMillis=50 \
+ --class-path 'etc/:lib/*' \
+ clojure.main \
+ --main datomic.launcher \
+ <(
+ sed \
+ -e "s|@PORT@|$PORT|g" \
+ -e "s|@FILE@|$FILE|g" \
+ -e "s|@CACHEDIR@|$CACHEDIR|g" \
+ -e "s|@TEMPDATADIR@|$TEMPDATADIR|g" \
+ -e "s|@VALCACHESIZE@|$VALCACHESIZE|g" \
+ @SYSCONFDIR@/transactor.properties.tmpl |
+ tee /dev/stderr
+ )