mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
bug: fix picoToken is empty when gateway started by launcher (#2241)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user