-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Once the Server is Stopped It is Impossible to Start Again #148
Comments
This is a common "gotcha" in common lisp. This is because To restart you should use the following:
|
a bit of advice and an aside. In slime, you can restart common lisp without restarting emacs. At the REPL with a blank prompt, enter |
Thanks for the lesson! 👍 |
If I use this method of restarting the inferior-lisp process, will I lose what has been defined at the Top level? |
yes, because you are starting a fresh new common lisp process, you will need to re-load into lisp what you want to work on. Using your example, you will need to reload |
These three helper procedures might be handy for this case? ;; Using defparameter instead of defconstant
;; to stop SLIME from complaining
;; about re-defining +default-port+.
(defparameter +default-port+ 2500)
(defvar *server-handler* nil)
(defun start-server (&optional (port +default-port+))
(if *server-handler*
(princ "Server is already running. Use restart-server instead?")
(setf *server-handler*
(clack:clackup #'my-server-logic
:port port
:server :hunchentoot))))
(defun stop-server ()
(if *server-handler*
(progn
(clack:stop *server-handler*)
(setf *server-handler* nil)
(princ "Server stopped."))
(princ "Server is not even started yet.")))
(defun restart-server (&optional (port +default-port+))
(if (null *server-handler*)
(princ "Server is not even started yet.")
(progn
(princ "Restarting server..")
(stop-server)
(start-server port))))
|
What is the cleanest way to stop a server without a handler? I started the server without binding the return value to a variable, so I have no obvious way (as a lisp newbie) of stopping it except to kill common lisp. Is there a better way?
EDIT: I managed to answer my own question... Within the REPL, the user can use If there are intervening commands/ouput, this is still quite doable, but you will have to use a different special variable depending on how far back you need to reference. The backreferences section of the SLY documentation will guide you. |
I followed the basic instructions on how to Start and Stop the Clack located on the front page of this repo. I discovered that once the server is stopped using:
(clack:stop *handler*)
It is impossible to start it again using:
To start it again, I always need to restart the Emacs. It appears that the
*handler*
variable does not fully capture the running server. Hence, when one stops it and then tries to start the server again on the same port, there are still some remnants of the previous instance present.The text was updated successfully, but these errors were encountered: