Shirakumo / radiance

A Common Lisp web application environment
https://shirakumo.github.io/radiance/
zlib License
311 stars 19 forks source link

Radiance shouldn't attempt to connect to database during build #53

Closed sirherrbatka closed 2 years ago

sirherrbatka commented 2 years ago

My issue is this bit:

Performing boot to load required interfaces

This essentially requires having a functional and accessible database during build time. It is a problem when constructing a CI pipeline as it makes the build phase not well separated from the deploy.

Shinmera commented 2 years ago

I'm confused. Should it or should it not connect to the DB during build?

sirherrbatka commented 2 years ago

Should not. Pardon my mistake in the issue title.

Shinmera commented 2 years ago

Ok. I suppose instead of the boot shortcut it'll have to manually load interfaces and :startup modules.

sirherrbatka commented 2 years ago

Would simply disabling the startup hook during build would suffice as a workaround?

Shinmera commented 2 years ago

Maybe, but it sounds like a pretty bad hack.

sirherrbatka commented 2 years ago

Regrettably, I don't understand the inner workings of radiance well enough to create a decent merge request :(

Shinmera commented 2 years ago

Try this patch

From b495b37808bd66ed80616569eb8f1290f105a61b Mon Sep 17 00:00:00 2001
From: Shinmera <shinmera@tymoon.eu>
Date: Thu, 26 May 2022 14:28:53 +0200
Subject: [PATCH] Simulate boot in deploy.

---
 deploy.lisp | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/deploy.lisp b/deploy.lisp
index 446a0cb..fd38c2d 100644
--- a/deploy.lisp
+++ b/deploy.lisp
@@ -18,9 +18,15 @@
   (when (boundp 'cl-user::modules)
     (dolist (module (symbol-value 'cl-user::modules))
       (asdf:load-system module)))
-  (deploy:status 1 "Performing boot to load required interfaces")
-  (radiance:startup)
-  (radiance:shutdown)
+  (deploy:status 1 "Simulating boot to load required interfaces")
+  
+  (setf (environment) (or *environment* "default"))
+  (load-implementation 'logger)
+  (load-implementation 'server)
+  (dolist (module (config :startup))
+    #+quicklisp (ql:quickload module)
+    #-quicklisp (asdf:load-system module))
+  
   ;; Clear ASDF/QL
   (mapc #'asdf:register-immutable-system (asdf:already-loaded-systems))
   (asdf:clear-source-registry)
-- 
2.36.1
sirherrbatka commented 2 years ago

Yeah, this seems to work fine. Line (setf (environment) environment) is not required as far as I can tell.

sirherrbatka commented 2 years ago

Do you plan to put this patch on the upstream?

Shinmera commented 2 years ago

Just did in a723783

sirherrbatka commented 2 years ago

Great! Thanks for your help.