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

temporary build folder in /tmp not deleted #95

Closed
dhax opened this issue Jan 22, 2025 · 9 comments
Closed

temporary build folder in /tmp not deleted #95

dhax opened this issue Jan 22, 2025 · 9 comments

Comments

@dhax
Copy link

dhax commented Jan 22, 2025

After a normal "go run ." the temporary linux folder in /tmp/go-build123123 gets deleted again when the program stops. But the way "htmgo run" exits by killing the process seems to prevent the deletion of this temporary folder and in "htmgo watch" mode this happens on every save, leaving an orphaned build folder back... totally filled up my /tmp over a day ;)

As a quick fix replacing SIGKILL with SIGINT in pid_unix.go restores folder deletion.

@maddalax
Copy link
Owner

Thanks, I'll take a look tomorrow. I am a little worried that SIGINT will affect hot reload speed since it has to wait for the process to fully stop, which generally I don't care that much about in dev. I'll speed test that or maybe try something else like have htmgo run use a specific out dir that just keeps overwritten instead of temp

@maddalax
Copy link
Owner

maddalax commented Jan 24, 2025

Should be fixed in this release.

https://github.com/maddalax/htmgo/releases/tag/cli%2Fhtmgo%2F1.0.6

to update your CLI, run:

GOPROXY=direct go install github.com/maddalax/htmgo/cli/htmgo@latest

I ended up just making it so the output dir is consistent and it gets cleaned up each time.

@dhax
Copy link
Author

dhax commented Jan 26, 2025

Thanks, that should work fine.
Also wanted to mention that sometimes on reload I experience a complete firefox browser crash and think it might be triggered by the restart logic for ListenAndServe

cmd := exec.Command("bash", "-c", fmt.Sprintf("kill -9 $(lsof -ti%s)", port))

Maybe the app shouldn't try to kill processes itself and leave that to the runner and watcher.

@maddalax
Copy link
Owner

When you experience the crash, are you manually doing the reload or are you waiting for the live reload to refresh the page automatically?

@dhax
Copy link
Author

dhax commented Jan 27, 2025 via email

@dhax
Copy link
Author

dhax commented Jan 27, 2025

so it's basically reproducible by having 'htmgo run' in a terminal, open browser (here firefox) to connect to the livereloading endpoint and start 'htmgo watch' in another terminal. That's about the same situation when the process sometimes could not be killed/restarted properly. It happens only randomly, maybe every 30 to 50 saves though...

@maddalax
Copy link
Owner

maddalax commented Jan 27, 2025

Oh you are running htmgo run and htmgo watch at the same time? You should only need to run one or the other.

htmgo watch is just htmgo run but auto restarts it when you make a change

or were you just running it that way to try to reproduce just now?

@dhax
Copy link
Author

dhax commented Jan 27, 2025 via email

@maddalax
Copy link
Owner

maddalax commented Jan 27, 2025

Got it, I'll see if I can figure out what is going on.

The main reason I have the app restarting itself is sometimes the port taken even after killing the old app process and all its children (likely due to the force kill), and the only way I could ensure I open the port back up is to kill the app if it fails to startup on the specified port

since the port can really be anything, the watcher doesn't know what port the server runs on, therefore the server has to handle the reload

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

2 participants