Skip to content

fix(net/ghttp): windows web admin restart only shutdowns but doesn't restart#4809

Open
lonevle wants to merge 1 commit into
gogf:masterfrom
lonevle:fix/windows-restart-bug
Open

fix(net/ghttp): windows web admin restart only shutdowns but doesn't restart#4809
lonevle wants to merge 1 commit into
gogf:masterfrom
lonevle:fix/windows-restart-bug

Conversation

@lonevle

@lonevle lonevle commented Jul 24, 2026

Copy link
Copy Markdown

fix: Windows web admin restart only shutdowns but doesn't restart

Problem

On Windows, accessing /debug/admin/restart only shuts down the server but does not restart it. The process exits after printing all servers shutdown, and no new process is started.

Root Cause

In the Windows branch of restartWebServers, forceCloseWebServers(ctx) is called before forkRestartProcess:

gtimer.SetTimeout(ctx, time.Second, func(ctx context.Context) {
    forceCloseWebServers(ctx)                             // closes servers
    if err := forkRestartProcess(ctx, ...); err != nil {  // never executes
        intlog.Errorf(ctx, `%+v`, err)
    }
})

Closing the servers triggers closeChanRun() returns → main() returns → process exits. So forkRestartProcess never gets a chance to execute.

Fix

Remove forceCloseWebServers(ctx). The new process already kills its parent in serverProcessInit() before binding the port (this is the original design intent, see the comment in ghttp_server.go):

// serverProcessInit() - called before port binding in Start()
if !genv.Get(adminActionRestartEnvKey).IsEmpty() {
    p, _ := os.FindProcess(gproc.PPid())
    p.Kill()
    p.Wait()  // synchronous: port is released before binding
}

Notes

  • Only the web-admin path (signal == nil) is fixed.
  • The signal != nil branch is untouched (Windows does not register restart signals).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant