Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
zundaren opened this issue Apr 18, 2024 · 0 comments
Open

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

zundaren opened this issue Apr 18, 2024 · 0 comments
Labels
Enhancement New feature or request

Comments

@zundaren
Copy link

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

@zundaren zundaren added the Enhancement New feature or request label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant