Open girng opened 5 years ago
I think this is intended behavior. At least, I like this being the intended behavior :) It gives minimal downtime while your app is re-compiling, then once it's ready it will kill the process and restart it with the new binary.
I find this nice on larger projects where compile times can be >10 seconds and I'm, for example, working on a website where I can continue using it to get ready to test my changes once it launches again.
I am coming from nodejs and there was a similar thing like this, but it restarted the process instantly on save. Maybe I'm just use to that
Interesting. Which reloader were you using in node? My experience with things like Webpack and Parcel was essentially the same as Sentry: the process was left running until the recompilation finished. Though, in those cases it was just replacing files, not actually restarting the server.
Sentry's current behavior also matches what I expect coming from Ruby on Rails, Django, and Flask's reloaders.
I think an additional rationale for this behavior with Crystal is that extended compilation time. Even small programs will take 3-5 seconds to compile, whereas a lot of interpreted languages or faster compilers work in tenths of a second.
IIRC, it was supervisor
https://github.com/petruisfan/node-supervisor
Right when I save my file, I want my gameserver to die, then re-compile. However, as you said, sentry already starts compiling. It's just the delay is what I am not used to, but in reality it's probably the same amount of time anyway
like @faultyserver said. Since Crystal takes longer to compile, I didn't want to try to stop the process in case the compilation fails and then your application is down and won't start.
So it will only kill the currently running process if there is another compiled binary ready to run.
The long compilation step HAS to occur so i thought you might as well preserve the app until there is something to replace it with. Dynamic languages like Node and Ruby don't really have that problem.
Well, for me, the entire point for saving a file is I am done, and ready to log in into my gameserver to test things. For me, compilation is around 5-7 seconds on WSL, so I can't really do much in that short amount of time anyway.
However, I think this is a placebo effect as it's still the same amount of time. It just feels different because I'm so used to the app being killed instantly on save.
@girng
For me, compilation is around 5-7 seconds on WSL, so I can't really do much in that short amount of time anyway.
if compilation fails, you'll have a lot longer than 5-7 seconds. From what I've experienced, when i'm doing a major refactor and my service has compilation errors, its nice to still have a running app to see the current behavior while i fix things. The old binary is like a snapshot of the last time my app was healthy that I can run until a new one is produced.
Well, for me, the entire point for saving a file is I am done, and ready to log in into my gameserver to test things.
Yeah that makes sense in dynamic programming language, where the source code is the executable. But your gameserver doesn't run Crystal source code, it runs executable binaries generated by the Crystal compiler. Sentry only needs to restart the app when a new binary is produced. So in a sense, it is killing the service as soon as you make a change to the executable binary.
I think this is a placebo effect
Maybe. Maybe not, though. Crystal does make everything feel slower during development. But i don't know if there is any benefit to killing the process right after changing source code, since you'll still have to sit there for 5-7 seconds while it compiles... so it will still feel slow IMO 🤷♂️
its nice to still have a running app to see the current behavior
Interesting. For me, I don't ever reach this step. When I hit save I'm totally done and not worried about code or "current behavior", i'm solely just waiting for the compilation process to finish ASAP so I can test my app. I think maybe people just have different workflows lol
This shard is awesome! However, when I save a file, my app still continues to run, for example:
I there a way for when I save my file, my process is killed?
I'm on WSL.. I bet that could be why it's not working correctly :(