metasoarous / toto

Static site generation in Clojure (with live code reloading!)
Eclipse Public License 1.0
111 stars 3 forks source link

Server doesn't seem to start until something in site-src is touched #4

Closed eneroth closed 3 years ago

eneroth commented 3 years ago

localhost:5760 doesn't seem to be available until something in site-src is touched.

Teething problems or feature? 🙂

avocade commented 3 years ago

Same issue here.

eneroth commented 3 years ago

Discovered that this is a feature.

metasoarous commented 3 years ago

Hey; Thanks for posting.

Actually, for me the server/browser-tab opens immediately on calling build!, though this may only be the case if there is already content in the :from directory, or perhaps if :lazy-build? true is set. I could see an argument for making sure this always happens though. Can you please share why you decided not doing so is a feature?

Thanks

avocade commented 3 years ago

For me it usually takes at least 5 seconds for it to open up in the browser (I'm on a MBP15 from 2017) after I start the build!. Sometimes it doesn't launch at all. But it always seems to require me to at least save/touch a file in site_src before the compilation starts, even with lazy? turned off.

From my POV it would be great if it always rendered everything in site_src/ every time you run build!, even if there's already content in the build/ folder. Often it happens that I edit the clj/md files without the server active, and it's confusing to see an old version of the rendered files after I start up the server.

metasoarous commented 3 years ago

Thanks for the update.

This is actually how build! is supposed to behave if lazy? is false. I remember there had been a bug with this, and I thought I had fixed it, but may not have. I'll take another look at this.

The 5 second pause is there because it takes some time for the sente websockets connection to get established, and messages that get sent before the connection is established fail to reach the client. A smarter thing to do would be to have the client submit a heartbeat message on connection (which might be a little tricky, because I think the client has the same problem) so that the server knows when the client is ready for messages. If nothing is showing up after 5 secs though, that would be a bug (unless the socket is taking that long to set up, which seems unlikely). So please let me know if you continue to see this. I haven't personally had problems with it, but there may be something specific going on.

Thanks again