Restart restarts (aka. replaces) the current running application process. NB! It relies on execve which is supported only on UNIX based systems.
()
| 753 | // |
| 754 | // NB! It relies on execve which is supported only on UNIX based systems. |
| 755 | func (app *BaseApp) Restart() error { |
| 756 | if runtime.GOOS == "windows" { |
| 757 | return errors.New("restart is not supported on windows") |
| 758 | } |
| 759 | |
| 760 | execPath, err := os.Executable() |
| 761 | if err != nil { |
| 762 | return err |
| 763 | } |
| 764 | |
| 765 | event := &TerminateEvent{} |
| 766 | event.App = app |
| 767 | event.IsRestart = true |
| 768 | |
| 769 | return app.OnTerminate().Trigger(event, func(e *TerminateEvent) error { |
| 770 | _ = e.App.ResetBootstrapState() |
| 771 | |
| 772 | // attempt to restart the bootstrap process in case execve returns an error for some reason |
| 773 | defer func() { |
| 774 | if err := e.App.Bootstrap(); err != nil { |
| 775 | app.Logger().Error("Failed to rebootstrap the application after failed app.Restart()", "error", err) |
| 776 | } |
| 777 | }() |
| 778 | |
| 779 | return execve(execPath, os.Args, os.Environ()) |
| 780 | }) |
| 781 | } |
| 782 | |
| 783 | // RunSystemMigrations applies all new migrations registered in the [core.SystemMigrations] list. |
| 784 | func (app *BaseApp) RunSystemMigrations() error { |
nothing calls this directly
no test coverage detected