bug: fix picoToken is empty when gateway started by launcher (#2241)

This commit is contained in:
Cytown
2026-04-01 14:59:18 +08:00
committed by GitHub
parent f327859cce
commit a9c76eca21
4 changed files with 21 additions and 29 deletions
+1
View File
@@ -149,6 +149,7 @@ func Run(debug bool, homePath, configPath string, allowEmptyStartup bool) error
// Enforce singleton: write PID file with generated token.
pidData, err := pid.WritePidFile(homePath, cfg.Gateway.Host, cfg.Gateway.Port)
if err != nil {
logger.Warnf("write pid file failed: %v", err)
return fmt.Errorf("singleton check failed: %w", err)
}
defer pid.RemovePidFile(homePath)
+3
View File
@@ -94,6 +94,7 @@ func WritePidFile(homePath, host string, port int) (*PidFileData, error) {
os.Remove(tmp)
return nil, fmt.Errorf("failed to rename pid file: %w", err)
}
logger.Debugf("wrote pid file: %s success", pidPath)
return data, nil
}
@@ -108,10 +109,12 @@ func ReadPidFileWithCheck(homePath string) *PidFileData {
pidPath := pidFilePath(homePath)
data, err := readPidFileUnlocked(pidPath)
if err != nil {
logger.Debugf("failed to read pid file: %s", err)
return nil
}
if !isProcessRunning(data.PID) {
logger.Debugf("process not running, remove pid file: %s", pidPath)
os.Remove(pidPath)
return nil
}