pedestal / pedestal-docs

Documentation for Pedestal.
http://pedestal.io
42 stars 55 forks source link

Question about "Interactive Development": Changes not reflected when restarting server #156

Open fhightower opened 3 years ago

fhightower commented 3 years ago

This is a question about the "Interactive Development" section of the Hello World guide. I'm new to Pedestal and relatively new to Clojure, so please pardon any ignorance on display in this question.

In the interactive development section, we add various functions (e.g. start-dev and stop-dev) to hello.clj. When I added these functions, however, it did not work as I expected and I would like to know if I did something wrong or if my expectations are wrong (or something else entirely).

I copied the whole shebang into hello.clj to make sure I had the correct content. I then started the server in clj with:

(require 'hello)
(hello/start-dev)

This starts the server as expected. I then make a change to hello.clj and run (hello/restart) in the REPL. At this point, I expected the server to restart with the changes I made to hello.clj, but it does not. It restarts the server, but does not reflect the changes I made. So every time I make changes, I need to restart the REPL every time. I'm confused because the prose under the heading here makes it sound as though we should not have to restart the REPL every time we make a change. Am I doing something wrong or are my expectations wrong (or something else entirely)?

Thanks in advanced for any insight!

fhightower commented 3 years ago

I have an update on this (although my question still stands):

Based on my research, if you use the whole shebang and run:

(require 'hello)
(hello/start-dev)

And then make a change to hello.clj, you can reload it using:

(require :reload 'hello)
(hello/restart)

But I expected only (hello/restart) to be required to restart the server with the updated content based on the following statement here:

Now we can use start-dev, stop-dev, and restart as we make changes.

Again, my original questions still stand: Am I doing something wrong? Are my expectations wrong? Should the post be updated to clarify that (hello/restart) must be preceded with (require :reload 'hello) for it to restart the server with updated code?