#!/bin/sh
# The fastest way to start Suave: one Deno process with a big stack (so deep recursion works).
# Put this folder on your PATH, or copy/link this file somewhere that is.
SELF="$0"
while [ -L "$SELF" ]; do T=$(readlink "$SELF"); case "$T" in /*) SELF="$T";; *) SELF="$(dirname "$SELF")/$T";; esac; done
HERE=$(cd "$(dirname "$SELF")" && pwd)
ulimit -s 65500 2>/dev/null || ulimit -s 32000 2>/dev/null
L=$(ulimit -s)
if [ "$L" = unlimited ]; then S=60000; elif [ "$L" -ge 60000 ]; then S=58000; else S=$((L * 85 / 100)); fi
if [ "$S" -ge 50000 ]; then D=150000; else D=$S; fi
SUAVE_CHILD=1 SUAVE_MAX_DEPTH=$D exec deno run -A --quiet --v8-flags=--stack-size=$S "$HERE/main.js" laker "$@"
