Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

application start & stop

  • Loading branch information...
commit db760e023de3c5ee48e785570fe6a2848fc5f4eb 1 parent 9015438
asdr the admin authored
26 application-handler.lisp
View
@@ -20,22 +20,41 @@
(let* ((starter (get-easy-starter :address address
:port port))
(acceptor (easy-starter-acceptor starter)))
- (when (and starter
- acceptor)
+ (when (and starter acceptor)
(application-load application-name :acceptor-name (hunchentoot:acceptor-name acceptor))
+ (pushnew application-name (easy-starter-applications starter))
(hunchentoot:start acceptor)
(format t "Application started: ~S~%" application-name)))))
+(defun application-stop (application-name &optional (acceptor-name (format nil
+ "(~A . ~A)"
+ *listen-address*
+ *listen-port*)))
+ (when application-name
+ (let ((starter (gethash acceptor-name *acceptor-table*)))
+ (when starter
+ (let ((acceptor (easy-starter-acceptor starter)))
+ (when acceptor
+ (application-unload application-name :acceptor-name (hunchentoot:acceptor-name acceptor))
+ (format t "Application stopped: ~S~%" application-name)
+ (setf (easy-starter-applications starter) (delete-if #'(lambda(obj)
+ (string= application-name obj))
+ (easy-starter-applications starter)))
+ (when (zerop (length (easy-starter-applications starter)))
+ (hunchentoot:stop acceptor)
+ (format t "Acceptor stopped: ~S~%" (hunchentoot:acceptor-name acceptor)))))))))
+
(defun application-load (application-name &key acceptor-name)
(loop
for context in *application-contexts*
when (and context
(string-equal application-name (context-name context)))
do (if (null acceptor-name)
- (setf (context-acceptor-status-list context) (list (cons nil t)))
+ (setf (context-acceptor-status-list context) (list (cons (nil t))))
(if (member acceptor-name (context-acceptor-status-list context) :test #'string= :key #'car)
(setf (cdr (context-acceptor-status-list context)) t)
(push (cons acceptor-name t) (context-acceptor-status-list context))))))
+
(defun application-unload (application-name &key acceptor-name)
(loop
@@ -167,3 +186,4 @@
default-parameter-type
default-request-type)))
,@body))))
+
1  defpackage.lisp
View
@@ -4,6 +4,7 @@
(:use #:cl)
(:export ;;APPLICATION-HANDLER
#:application-start
+ #:application-stop
#:application-load
#:application-unload
#:define-url-patterns
2  easyweb.asd
View
@@ -16,8 +16,8 @@
:components ((:file "defpackage")
(:file "util")
(:file "settings")
- (:file "application-handler")
(:file "server")
+ (:file "application-handler")
(:file "misc")
(:file "application-util")
(:file "html")
10 server.lisp
View
@@ -2,7 +2,6 @@
(defstruct (easy-starter)
"Easy Starter"
- handle
acceptor
applications)
@@ -18,7 +17,10 @@
(defparameter *swank-port* 4991)
-(defparameter *swank* nil)
+
+;;start swank server
+(defparameter *swank*
+ (swank:create-server :port *swank-port* :dont-close t))
(defun easy-starter-hash (address port)
(format nil "~A" (cons address port)))
@@ -31,8 +33,12 @@
:address address
:port port
:name key))))))
+ ;(defmethod get-easy-starter (acceptor-name)
+ ; (gethash acceptor-name *acceptor-table*))
+
(defun get-acceptor (&key (port *listen-port*) (address *listen-address*))
(let ((starter (get-easy-starter address port)))
(when starter
(easy-starter-acceptor starter))))
+
Please sign in to comment.
Something went wrong with that request. Please try again.