From a5a5b69d3b96aa890909068e45c443460d52a697 Mon Sep 17 00:00:00 2001 From: Uko Kokņevičs Date: Sun, 19 Oct 2025 09:02:59 +0300 Subject: Work on launching scripts a bit --- README.md | 6 ++---- launch.sh | 15 +++++++++++++++ run-tests.sh | 4 +++- src/main.lisp | 18 ++++++++---------- 4 files changed, 28 insertions(+), 15 deletions(-) create mode 100755 launch.sh diff --git a/README.md b/README.md index 34f0771..22acd03 100644 --- a/README.md +++ b/README.md @@ -2,10 +2,8 @@ A shitty small telegram bot written in Common Lisp. -When running in a debuggy environment, consider -``` common-lisp -(setf ukkoclot::*in-prod* nil) -``` +For running the (very few) tests and other repository maintaining things, run `./run_tests.sh`. For having an example +way how to launch, see `./launch.sh`. # Licensing diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..795db47 --- /dev/null +++ b/launch.sh @@ -0,0 +1,15 @@ +#!/bin/sh +# SPDX-License-Identifier: EUPL-1.2 +# SPDX-FileCopyrightText: 2025 Uko Kokņevičs + +set -eu + +# Note this still has the debugger and such things enabled, at this point it makes life easier for me :). For a more +# hands-off auto-restarting approach, consider disabling all the fancy SBCL things (similar to ./run_tests.sh) and +# putting it in a shell while true loop. + +exec sbcl \ + --eval '(asdf:load-system :ukkoclot)' \ + --eval '(log:config :debug :sane2)' \ + --eval '(setf ukkoclot::*in-prod* t)' \ + --eval '(ukkoclot:main)' diff --git a/run-tests.sh b/run-tests.sh index b2bbdb9..276274b 100755 --- a/run-tests.sh +++ b/run-tests.sh @@ -7,6 +7,8 @@ set -eu exec sbcl \ --disable-ldb --lose-on-corruption \ --noinform --noprint --non-interactive \ - --eval '(asdf:load-system :ukkoclot/test/all :verbose t)' \ + --eval '(asdf:load-system :ukkoclot)' \ + --eval '(conf:print-default #P"config.default.lisp")' \ + --eval '(asdf:load-system :ukkoclot/test/all)' \ --eval '(setf ukkoclot/test/all:*should-quit* t)' \ --eval '(asdf:test-system :ukkoclot)' diff --git a/src/main.lisp b/src/main.lisp index fa7fab0..e68ca40 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -20,26 +20,24 @@ (enable-f-strings) -(defvar *in-prod* t) - -(defmacro reporty ((evt) &body body) - `(cond - (*in-prod* - (handler-case (progn ,@body) ; lint:suppress redundant-progn - (error (err) (report-error ,evt err)))) - (t ,@body))) +(defvar *in-prod* nil) (defun main () - (log:config :debug) (unwind-protect (progn - (conf:print-default #P"config.default.lisp") (conf:load-config #P"config.lisp") (log:info "Starting up ~A" (conf:bot-name)) (main-with-config) nil) (log:info "Quitting!"))) +(defmacro reporty ((evt) &body body) + `(cond + (*in-prod* + (handler-case (progn ,@body) ; lint:suppress redundant-progn + (error (err) (report-error ,evt err)))) + (t ,@body))) + (defun main-with-config () (unwind-protect (with-db (db (conf:db-path)) -- cgit v1.2.3