summaryrefslogtreecommitdiff
path: root/src/init.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/init.lisp')
-rw-r--r--src/init.lisp31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/init.lisp b/src/init.lisp
index 68b2a16..d7636a6 100644
--- a/src/init.lisp
+++ b/src/init.lisp
@@ -2,11 +2,28 @@
(in-package #:dnd)
-(defun init-db (&optional config)
+;;; CONFIGURATION
+
+(defvar *config* nil)
+
+(defclass/std config ()
+ ((datastore-directory :ir :std #P"/srv/dnd/store/")
+ (swank-port :std nil :doc "If set, swank is started on this port.")
+ (host :std "0.0.0.0")
+ (port :ir :std 8888)))
+
+(defun config-from-file (path)
+ "PATH should be a path to a file containing a PLIST suitable for
+ passing as the keyword arguments to (MAKE-INSTANCE 'CONFIG ...)"
+ (apply #'make-instance 'config (read-from-file path)))
+
+;;; DATASTORE
+
+(defun init-db (config)
+ "Initializes the data store with values from the CONFIG."
+ (ensure-directories-exist (datastore-directory config))
(unless (boundp 'db:*store*)
- (unless config
- nil ; TODO: handle the case where we have a config
- (make-instance
- 'db:mp-store
- :directory (merge-pathnames "dnd-store/" (user-homedir-pathname))
- :subsystems (list (make-instance 'db:store-object-subsystem))))))
+ (make-instance
+ 'db:mp-store
+ :directory (datastore-directory config)
+ :subsystems (list (make-instance 'db:store-object-subsystem)))))