Skip to content

Commit

Permalink
Merge pull request #635 from Darkren/fix/vpn-start-stop
Browse files Browse the repository at this point in the history
Fix app startup issues after changing the args via UI
  • Loading branch information
jdknives authored Dec 16, 2020
2 parents 70ae839 + 3411998 commit 4233b30
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions pkg/app/appserver/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/app/launcher/launcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ func (l *Launcher) startApp(cmd string, args, envs []string) error {
if !ok {
return ErrAppNotFound
}

if args != nil {
ac.Args = args
}
Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 4233b30

Please sign in to comment.