diff --git a/pkg/app/appserver/proc.go b/pkg/app/appserver/proc.go index 855077b55e..5ae26d4ce8 100644 --- a/pkg/app/appserver/proc.go +++ b/pkg/app/appserver/proc.go @@ -162,6 +162,13 @@ func (p *Proc) Start() error { close(waitErrCh) }() + defer func() { + // here will definitely be an error notifying that the process + // is already stopped. We do this to remove proc from the manager, + // therefore giving the correct app status to hypervisor. + _ = p.m.Stop(p.appName) //nolint:errcheck + }() + select { case _, ok := <-p.connCh: if !ok { @@ -181,11 +188,6 @@ func (p *Proc) Start() error { // channel won't get closed outside, close it now. p.connOnce.Do(func() { close(p.connCh) }) - // here will definitely be an error notifying that the process - // is already stopped. We do this to remove proc from the manager, - // therefore giving the correct app status to hypervisor. - _ = p.m.Stop(p.appName) //nolint:errcheck - return } diff --git a/pkg/app/launcher/launcher.go b/pkg/app/launcher/launcher.go index 4a059579a2..f864bc3564 100644 --- a/pkg/app/launcher/launcher.go +++ b/pkg/app/launcher/launcher.go @@ -208,6 +208,7 @@ func (l *Launcher) startApp(cmd string, args, envs []string) error { if !ok { return ErrAppNotFound } + if args != nil { ac.Args = args } @@ -260,8 +261,7 @@ func (l *Launcher) RestartApp(name string) error { } cmd := proc.Cmd() - // complete list of args includes binary name which is not needed, so omit it - if err := l.StartApp(name, cmd.Args[1:], cmd.Env); err != nil { + if err := l.StartApp(name, nil, cmd.Env); err != nil { return fmt.Errorf("failed to start %s: %w", name, err) }