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

App is still running even after a file is saved #44

Open
girng opened this issue Oct 8, 2019 · 8 comments
Open

App is still running even after a file is saved #44

girng opened this issue Oct 8, 2019 · 8 comments

Comments

@girng
Copy link

girng commented Oct 8, 2019

This shard is awesome! However, when I save a file, my app still continues to run, for example:

Games Open: 0. Game Iterations: 0, Msgs Sent: 0
Games Open: 0. Game Iterations: 0, Msgs Sent: 0
Games Open: 0. Game Iterations: 0, Msgs Sent: 0
Games Open: 0. Game Iterations: 0, Msgs Sent: 0
🤖  ./src/GameFunctions.cr
🤖  compiling GameServer...
Games Open: 0. Game Iterations: 0, Msgs Sent: 0
Games Open: 0. Game Iterations: 0, Msgs Sent: 0
Games Open: 0. Game Iterations: 0, Msgs Sent: 0

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 :(

@faultyserver
Copy link
Contributor

faultyserver commented Oct 8, 2019

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.

@girng
Copy link
Author

girng commented Oct 9, 2019

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

@faultyserver
Copy link
Contributor

faultyserver commented Oct 9, 2019

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.

@girng
Copy link
Author

girng commented Oct 9, 2019

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

@samueleaton
Copy link
Owner

samueleaton commented Oct 11, 2019

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.

@girng
Copy link
Author

girng commented Oct 11, 2019

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.

@samueleaton
Copy link
Owner

@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 🤷‍♂️

@girng
Copy link
Author

girng commented Oct 14, 2019

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

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

No branches or pull requests

3 participants