F1bonacc1 / process-compose

Process Compose is a simple and flexible scheduler and orchestrator to manage non-containerized applications.
https://f1bonacc1.github.io/process-compose/
Apache License 2.0
1.33k stars 52 forks source link

tui: don't log.Fatal on appView.Run error #246

Closed gcurtis closed 2 months ago

gcurtis commented 2 months ago

When the user closes their terminal (as opposed to ctrl-c), the terminal might close the tty without waiting for process-compose to exit. This causes pcv.appView.Run to return an error, which triggers a log.Fatal:

ERR Failed to start TUI error="read /dev/tty: input/output error"

This leads to a race where log.Fatal might call os.Exit before the project's processes can be stopped, leaving them orphaned.

Change log.Fatal to log.Error and explicitly shutdown the project to make sure processes aren't left behind.

sonarcloud[bot] commented 2 months ago

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

gcurtis commented 2 months ago

Hey @F1bonacc1, this is something we ran into when running devbox services up (which runs the process-compose TUI) in the VS Code terminal. Let me know if this fix makes sense. It seems to eliminate the race, but it's also a bit tricky to test.