|
- #|
-
- src/config.lisp
-
- Configuration skeleton generated by Caveman.
-
- Additional changes:
-
- *public-directory* :: This is where YGOProDeck images and things generated *by the "public" are stored.
-
- Database Configuration:
-
- We use :MEMORY for SQLite in-memory,currently :MAINDB is the default
- database which is an SQLite3 file in this directory, and :MYSQL is our
- MariaDB testbed server we're planning on migrating to.
-
- |#
-
- (in-package :cl-user)
-
- (defpackage #:cl-deck-builder2.config
- (:use #:cl)
- (:import-from #:envy
- #:config-env-var
- #:defconfig)
- (:export #:config
- #:*application-root*
- #:*public-directory*
- #:*static-directory*
- #:*template-directory*
-
- #:*app-log-file*
-
- #:appenv
- #:developmentp
- #:productionp)
- (:documentation "Configuration package. Using Envy configuration switcher. Mostly default from Caveman2 skeleton generator. I added a bunch of documentation."))
-
- (in-package :cl-deck-builder2.config)
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-
- (setf (config-env-var) "APP_ENV")
-
- (defparameter *application-root*
- (asdf:system-source-directory :cl-deck-builder2)
- "The source directory of this web application.")
- (defparameter *public-directory*
- (probe-file #P"~/public/")
- "The absolute path to the directory where we serve public files from.")
- (defparameter *static-directory*
- (merge-pathnames #P"static/" *application-root*)
- "The absolute path to the directory where we serve static files from.")
- (defparameter *template-directory*
- (merge-pathnames #P"templates/" *application-root*)
- "The absolute path to the directory where we find and compile templates from.")
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defparameter *app-log-file*
- (merge-pathnames
- (make-pathname
- :name (local-time:format-timestring
- nil (local-time:now)
- :format local-time:+rfc3339-format/date-only+)
- :type "log")
- (merge-pathnames
- *public-directory*
- (user-homedir-pathname)))
- "The log file for this instance of the app to use. We don't really care about conflicts at this point, as we :APPEND.
-
- Possibly in the future use the git commit id.")
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- ;; Configurations
- (defconfig :common
- `(:databases
- ((:memory :sqlite3 :database-name ":memory:")
- (:maindb :sqlite3 :database-name
- ,(asdf:system-relative-pathname
- :cl-deck-builder2 "deck_builder" :type "sqlite3"))
- (:mysql :mysql
- :host "127.0.0.1"
- :port 3306
- :database-name "deck_builder"
- :username "deck_builder"
- :password "deck_builder"))
- :server (:address "0.0.0.0" :port 5005 :server :woo)
- :slynk (:interface "0.0.0.0"
- :port 4005
- :style :spawn
- :dont-close t)
- :websocket (:address "0.0.0.0" :port 5001)))
-
- (defconfig |development|
- '())
-
- (defconfig |production|
- '())
-
- (defconfig |test|
- '())
-
- ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (defun config (&optional key)
- "Query the configuration environment information.
-
- ARGUMENTS
- KEY The key to query from the configuration."
- (envy:config #.(package-name *package*) key))
-
- (defun appenv ()
- "Get the current environment variable value. Default is ~APP_ENV~."
- (uiop:getenv (config-env-var #.(package-name *package*))))
-
- (defun developmentp ()
- "Return T if the application is in \"development\" mode."
- (string= (appenv) "development"))
-
- (defun productionp ()
- "Return T if the application is in \"production\" mode."
- (string= (appenv) "production"))
|