mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 21:35:54 +03:00
[GH-ISSUE #318] Graceful shutdown #243
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#243
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @kennykarnama on GitHub (Jun 29, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/318
Hi it is very awesome library. Actually i try to build a simple app, that run music in background when displaying pages. The problem arose because my golang version doesn't support syscall/js. so i try another way by using ffplayer invoked by using exec function in golang. I have already create the stop function in order to stop the music when the ui got closed (normally). But here is the trouble i found, when we give interrupt signal (ctrl+c), it is caught by thread of tview. and stop the application, but not the ffplayer that has been run before. So, the graceful shutdown scheme not work quite well.
so, just wondering, how about we implement wrapper pattern inside the stop function in twview ?
cause by doing that i was able to gracefully shutdown all the goroutine. Here is my current solution :
on the existing code, inside the event loop in start()
it would be better if i just show my PR ? thanks
@rivo commented on GitHub (Jul 10, 2019):
Have you tried
Application.SetInputCapture()? The description explicitly says:When you detect a Ctrl-C, you can also perform any other cleanup.
Without knowing the details of your program, however, I would think that cleaning up your threads could go at the end of your program (i.e. after the
Run()function). Even in the case of aCtrl-Cinterrupt signal, that part of your program should still be executed.