diff options
| -rw-r--r-- | README.md | 6 | ||||
| -rwxr-xr-x | launch.sh | 15 | ||||
| -rwxr-xr-x | run-tests.sh | 4 | ||||
| -rw-r--r-- | src/main.lisp | 18 |
4 files changed, 28 insertions, 15 deletions
| @@ -2,10 +2,8 @@ | |||
| 2 | 2 | ||
| 3 | A shitty small telegram bot written in Common Lisp. | 3 | A shitty small telegram bot written in Common Lisp. |
| 4 | 4 | ||
| 5 | When running in a debuggy environment, consider | 5 | For running the (very few) tests and other repository maintaining things, run `./run_tests.sh`. For having an example |
| 6 | ``` common-lisp | 6 | way how to launch, see `./launch.sh`. |
| 7 | (setf ukkoclot::*in-prod* nil) | ||
| 8 | ``` | ||
| 9 | 7 | ||
| 10 | # Licensing | 8 | # Licensing |
| 11 | 9 | ||
diff --git a/launch.sh b/launch.sh new file mode 100755 index 0000000..795db47 --- /dev/null +++ b/launch.sh | |||
| @@ -0,0 +1,15 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # SPDX-License-Identifier: EUPL-1.2 | ||
| 3 | # SPDX-FileCopyrightText: 2025 Uko Kokņevičs <perkontevs@gmail.com> | ||
| 4 | |||
| 5 | set -eu | ||
| 6 | |||
| 7 | # Note this still has the debugger and such things enabled, at this point it makes life easier for me :). For a more | ||
| 8 | # hands-off auto-restarting approach, consider disabling all the fancy SBCL things (similar to ./run_tests.sh) and | ||
| 9 | # putting it in a shell while true loop. | ||
| 10 | |||
| 11 | exec sbcl \ | ||
| 12 | --eval '(asdf:load-system :ukkoclot)' \ | ||
| 13 | --eval '(log:config :debug :sane2)' \ | ||
| 14 | --eval '(setf ukkoclot::*in-prod* t)' \ | ||
| 15 | --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 | |||
| 7 | exec sbcl \ | 7 | exec sbcl \ |
| 8 | --disable-ldb --lose-on-corruption \ | 8 | --disable-ldb --lose-on-corruption \ |
| 9 | --noinform --noprint --non-interactive \ | 9 | --noinform --noprint --non-interactive \ |
| 10 | --eval '(asdf:load-system :ukkoclot/test/all :verbose t)' \ | 10 | --eval '(asdf:load-system :ukkoclot)' \ |
| 11 | --eval '(conf:print-default #P"config.default.lisp")' \ | ||
| 12 | --eval '(asdf:load-system :ukkoclot/test/all)' \ | ||
| 11 | --eval '(setf ukkoclot/test/all:*should-quit* t)' \ | 13 | --eval '(setf ukkoclot/test/all:*should-quit* t)' \ |
| 12 | --eval '(asdf:test-system :ukkoclot)' | 14 | --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 @@ | |||
| 20 | 20 | ||
| 21 | (enable-f-strings) | 21 | (enable-f-strings) |
| 22 | 22 | ||
| 23 | (defvar *in-prod* t) | 23 | (defvar *in-prod* nil) |
| 24 | |||
| 25 | (defmacro reporty ((evt) &body body) | ||
| 26 | `(cond | ||
| 27 | (*in-prod* | ||
| 28 | (handler-case (progn ,@body) ; lint:suppress redundant-progn | ||
| 29 | (error (err) (report-error ,evt err)))) | ||
| 30 | (t ,@body))) | ||
| 31 | 24 | ||
| 32 | (defun main () | 25 | (defun main () |
| 33 | (log:config :debug) | ||
| 34 | (unwind-protect | 26 | (unwind-protect |
| 35 | (progn | 27 | (progn |
| 36 | (conf:print-default #P"config.default.lisp") | ||
| 37 | (conf:load-config #P"config.lisp") | 28 | (conf:load-config #P"config.lisp") |
| 38 | (log:info "Starting up ~A" (conf:bot-name)) | 29 | (log:info "Starting up ~A" (conf:bot-name)) |
| 39 | (main-with-config) | 30 | (main-with-config) |
| 40 | nil) | 31 | nil) |
| 41 | (log:info "Quitting!"))) | 32 | (log:info "Quitting!"))) |
| 42 | 33 | ||
| 34 | (defmacro reporty ((evt) &body body) | ||
| 35 | `(cond | ||
| 36 | (*in-prod* | ||
| 37 | (handler-case (progn ,@body) ; lint:suppress redundant-progn | ||
| 38 | (error (err) (report-error ,evt err)))) | ||
| 39 | (t ,@body))) | ||
| 40 | |||
| 43 | (defun main-with-config () | 41 | (defun main-with-config () |
| 44 | (unwind-protect | 42 | (unwind-protect |
| 45 | (with-db (db (conf:db-path)) | 43 | (with-db (db (conf:db-path)) |