enterlab / rente

Rente: Clojure, ClojureScript, Reagent (react) + Sente (web sockets). Heroku-ready!
http://enterlab.com
Eclipse Public License 1.0
57 stars 12 forks source link

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

Open hellonico opened 9 years ago

hellonico commented 9 years ago

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

hellonico commented 9 years ago

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 commented 9 years ago

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 commented 9 years ago

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

ioRekz commented 9 years ago

@hellonico I saw your post on https://github.com/ptaoussanis/sente/issues/96 Did you make any progress ?

luposlip commented 9 years ago

@hellonico ? :-)

louixs commented 7 years ago

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 commented 7 years ago

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

aaronpowered commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 6 years ago

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 commented 6 years ago

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