(blockId string, exitCode int)
| 648 | } |
| 649 | |
| 650 | func checkCloseOnExit(blockId string, exitCode int) { |
| 651 | ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout) |
| 652 | defer cancelFn() |
| 653 | blockData, err := wstore.DBMustGet[*waveobj.Block](ctx, blockId) |
| 654 | if err != nil { |
| 655 | log.Printf("error getting block data: %v\n", err) |
| 656 | return |
| 657 | } |
| 658 | closeOnExit := blockData.Meta.GetBool(waveobj.MetaKey_CmdCloseOnExit, false) |
| 659 | closeOnExitForce := blockData.Meta.GetBool(waveobj.MetaKey_CmdCloseOnExitForce, false) |
| 660 | if !closeOnExitForce && !(closeOnExit && exitCode == 0) { |
| 661 | return |
| 662 | } |
| 663 | delayMs := blockData.Meta.GetFloat(waveobj.MetaKey_CmdCloseOnExitDelay, 2000) |
| 664 | if delayMs < 0 { |
| 665 | delayMs = 0 |
| 666 | } |
| 667 | time.Sleep(time.Duration(delayMs) * time.Millisecond) |
| 668 | rpcClient := wshclient.GetBareRpcClient() |
| 669 | err = wshclient.DeleteBlockCommand(rpcClient, wshrpc.CommandDeleteBlockData{BlockId: blockId}, nil) |
| 670 | if err != nil { |
| 671 | log.Printf("error deleting block data (close on exit): %v\n", err) |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | func getLocalShellPath(blockMeta waveobj.MetaMapType) (string, error) { |
| 676 | shellPath := blockMeta.GetString(waveobj.MetaKey_TermLocalShellPath, "") |
no test coverage detected