diff options
| author | 2025-10-19 09:02:59 +0300 | |
|---|---|---|
| committer | 2025-10-19 09:02:59 +0300 | |
| commit | a5a5b69d3b96aa890909068e45c443460d52a697 (patch) | |
| tree | 8a5ac7fa7752b9008f23b216729bfbc2f2435ad8 /src | |
| parent | Make state be a global special variable (diff) | |
| download | ukkoclot-a5a5b69d3b96aa890909068e45c443460d52a697.tar.gz ukkoclot-a5a5b69d3b96aa890909068e45c443460d52a697.tar.xz ukkoclot-a5a5b69d3b96aa890909068e45c443460d52a697.zip | |
Work on launching scripts a bit
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.lisp | 18 |
1 files changed, 8 insertions, 10 deletions
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)) |