74a46e4dca9a28d51eead9de089c5cf1a8e443fd
[lineal.git] / src / webui / serv.lisp
blob74a46e4dca9a28d51eead9de089c5cf1a8e443fd
2 ; This file should be called from the toplevel directory.
3 ; You can call it like (load "src/webui/serv"),
4 ; use a system link,
5 ; or *default-pathname-defaults*
7 ;V Just in case user loaded this file first.V
8 (defpackage :lineal.devvars (:use :cl))
9 (in-package :lineal.devvars)
11 (format t "serv.lisp is loaded...~%")
13 (load (make-pathname :directory '(:relative "src")
14 :name "devvars"))
15 (load (make-pathname :directory '(:relative "src" "webui")
16 :name "devvars"))
18 (format t "No errors? Relative path is good...~%")
20 (format t "Using ASDF, you better have it loaded already...~%")
21 (use-package :asdf)
22 (format t "... looks like it worked.~%")
24 (format t "Loading package dependencies.~%")
26 ;V Load the required libraries using V
27 ;V functions best with the lisp. V
28 (mapcar
29 (lambda (pkg)
30 (format t "Loading ~A...~%" pkg)
31 #+(or :sbcl :mcl :ecl :cmucl)
32 (require pkg)
33 #-(or :sbcl :mcl :ecl :cmucl)
34 (asdf:operate 'asdf:load-op pkg)
35 (format t "... ~A loaded.~%" pkg))
36 (list :hunchentoot :cl-who :parenscript))
38 (format t "Compiling and loading source tree...~%")
39 ;V Compile and Load V
40 (compile-lineal :compile-all (boundp 'compile-all))
42 (format t "Generating JavaScript files if needed...~%")
43 (lineal.webui::recompile-ps)
44 (format t "... success! We are now w3c complaint!~%")
46 ;V Enact any config options.V
47 (when (boundp 'tmp-directory)
48 (ensure-directories-exist
49 (symbol-value 'tmp-directory))
50 (setf lineal.webui::*tmp-directory*
51 (symbol-value 'tmp-directory))
52 (format t "Custom tmp directory set to: ~A~%"
53 (truename (symbol-value 'tmp-directory))))
55 (when (boundp 'log-file)
56 (open (ensure-directories-exist
57 (symbol-value 'log-file))
58 :direction :probe :if-does-not-exist :create)
59 (setf (lineal.webui::log-file)
60 (symbol-value 'log-file))
61 (format t "Custom log file will be at: ~A~%"
62 (truename (symbol-value 'log-file))))
64 ;V Load up restore file.V
65 (when (boundp 'restore-from-file)
66 (let ((file (symbol-value 'restore-from-file)))
67 (unless (pathnamep file)
68 (setq file (make-pathname :name "captured_session")))
69 (format t "Restoring session from: \"~A\"...~%"
70 (namestring file))
71 (princ (lineal::local-restore file))
72 (fresh-line)))
74 ;V Start server at specified port. V
75 (let ((the-port (if (boundp 'port)
76 (symbol-value 'port) 41938)))
77 (format t "Starting Lineal on port ~A... " the-port)
78 (lineal.webui:start-server :port the-port)
79 (format t "OK~%Now point your bowser to ~
80 http://localhost:~A/ and have at it!~%"
81 the-port))
83 (import 'lineal::local-capture :cl-user)