summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Uko Kokņevičs2025-10-19 09:02:59 +0300
committerGravatar Uko Kokņevičs2025-10-19 09:02:59 +0300
commita5a5b69d3b96aa890909068e45c443460d52a697 (patch)
tree8a5ac7fa7752b9008f23b216729bfbc2f2435ad8
parentMake state be a global special variable (diff)
downloadukkoclot-a5a5b69d3b96aa890909068e45c443460d52a697.tar.gz
ukkoclot-a5a5b69d3b96aa890909068e45c443460d52a697.tar.xz
ukkoclot-a5a5b69d3b96aa890909068e45c443460d52a697.zip
Work on launching scripts a bit
-rw-r--r--README.md6
-rwxr-xr-xlaunch.sh15
-rwxr-xr-xrun-tests.sh4
-rw-r--r--src/main.lisp18
4 files changed, 28 insertions, 15 deletions
diff --git a/README.md b/README.md
index 34f0771..22acd03 100644
--- a/README.md
+++ b/README.md
@@ -2,10 +2,8 @@
2 2
3A shitty small telegram bot written in Common Lisp. 3A shitty small telegram bot written in Common Lisp.
4 4
5When running in a debuggy environment, consider 5For running the (very few) tests and other repository maintaining things, run `./run_tests.sh`. For having an example
6``` common-lisp 6way 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
5set -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
11exec 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
7exec sbcl \ 7exec 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))