Skip to content

Is it possible to add a "runtime.Restart()" api #3403

Open
@zundaren

Description

@zundaren

Is your feature request related to a problem? Please describe.

When the automatic upgrade program needs to restart the application, at present I am through the "cmd" way to control, but not elegant enough

Describe the solution you'd like

runtime.Restart()

func Restart() error {
	var cmd string
	if osutil.IsWindows() {
		cmd = strings.Join([]string{"taskkill /pid", u.Str(Pid), "/f", "; start", ProgramPath}, " ")
	} else if osutil.IsMac() {
		cmd = strings.Join([]string{"kill -9", u.Str(Pid), ";", ProgramPath}, " ")
	} else {
		cmd = strings.Join([]string{"kill -9", u.Str(Pid), ";", ProgramPath}, " ")
	}
	return osutil.StartExec(cmd)
}

Describe alternatives you've considered

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    EnhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions