Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how do you get server side clj to auto refresh on file save ? #1

Open
hellonico opened this issue Jan 21, 2015 · 12 comments
Open

how do you get server side clj to auto refresh on file save ? #1

hellonico opened this issue Jan 21, 2015 · 12 comments

Comments

@hellonico
Copy link

Frontend is working great .. but can't figure out the server side just yet .. and my head hurts with "component" still :)

@hellonico
Copy link
Author

So if I use the dev methods from user.clj, and calling (reset), I get the following looping for ever:

2015-Jan-21 18:02:21 +0900 Modrzyks-MacBook-Pro.local ERROR [taoensso.sente] - Bad event: null
2015-Jan-21 18:02:21 +0900 Modrzyks-MacBook-Pro.local ERROR [taoensso.sente] - Bad event: null

any idea ?

@luposlip
Copy link
Member

Hi Nicolas,

Actually, I don't. I haven't properly configured the components module yet, I guess. I haven't gotten the server reload to work properly anyway.

If you figure out how to do it, please let me know! And if you create a Pull Request fixing something, I'll be happy to integrate it.

Best,
Henrik

@ioRekz
Copy link

ioRekz commented Apr 3, 2015

I'm also trying to make it work. No success so far

@ioRekz
Copy link

ioRekz commented Apr 5, 2015

@hellonico I saw your post on taoensso/sente#96
Did you make any progress ?

@luposlip
Copy link
Member

luposlip commented May 6, 2015

@hellonico ? :-)

@louixs
Copy link

louixs commented Jul 27, 2016

Are you guys still having the server reload issue?
If so I have a sort of a work around for now.
It's done by using ring.middleware.reload .

Added following as dependency to project.clj
[ring/ring-devel "1.6.0-beta4"]

In server.clj I added the following in :require
[ring.middleware.reload :refer (wrap-reload)]

Then plugged in (wrap-reload) into the app handler in server.clj file like this:
(defn app [handler]
(let [ring-defaults-config
(-> site-defaults
(assoc-in
[:security :anti-forgery]
{:read-token (fn [req] (-> req :params :csrf-token))})
(assoc-in [:static :resources] "public"))]
(-> handler
(wrap-reload) ; <--- HERE!
(wrap-defaults ring-defaults-config)
(wrap-resource "/META-INF/resources"))))


Figwheel reloads the client and server seems to be picking up file change without stopping and rerunning lein run.

I noticed that I still need to reload browser after making changes to server side codes..

Next step would be to figure out how to auto-reload server on file change without reloading browser..

@luposlip
Copy link
Member

luposlip commented Sep 1, 2016

Thanks for your input!
Does it automatically reload the changes to the Sente related handlers?

@aaronpowered
Copy link

aaronpowered commented Jan 7, 2017

Can anyone confirm that louixs's solution is working? I just cant make it work..
tried adding :ring-handler rente.server/app to figwheel in the project file
tried as louixs said without it
tried both with ring 1.5.0 and 1.6.0-beta4
without lein reruns rente would be a 'dream-like' project template for me :(

@louixs
Copy link

louixs commented Jan 7, 2017

Hi @luposlip and @aaronpowered.

Unfortunately for some reason it's just not working at the moment after a quick re-test now... I don't think there has been any changes but I was fairly sure it was working when I posted above. Sorry that I can't provide you with a good news for now..

Server-side change is not reflected unless I redo lein run now.
I have been staying away from clojure/clojurescript development for over almost half a year due to painfully slow startup time for everything.. I'll try to give it a review to see if I can get it to work again..

@aaronpowered
Copy link

Thank you @louixs . I got some progress now:
wrap-reload is working fine for .clj files independent from the server, because it reloads the namespace, but doesnt restart the server. I copied ring.middleware.reload and now im working on a solution for rente..

@pdenno
Copy link

pdenno commented Jul 9, 2017

Hi,
Maybe this is related / maybe it is a different issue entirely. The way I understand the code, I expected to be able to do lein repl and then use user/run, user/reset etc. But those don't work.

luposlip points out that he might not have the component stuff worked out for server reload.

It looks to me at least that ws.clj around line 60 is wrong:

  (stop [component]
    (when ch-recv (async/close! ch-recv))
    (log/debug "WebSocket connection stopped")
    (:stop-the-thing component) ; <------should be  ((:stop-the-thing-component))
    (assoc component
      :ch-recv nil :connected-uids nil :send-fn nil :ring-handlers nil)))

That is, it is only accessing the stop function, not executing it. But that alone doesn't fix things. I think it might be that :stop-the-thing isn't set.

But I am not very familiar with this code.

@camdez
Copy link
Contributor

camdez commented Jul 29, 2017

@pdenno Not sure how much it helps (I'm just quickly scanning through this issue), but I fixed the issue you mention above in 7e2d256 (now merged).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants