Fixed the format

This commit is contained in:
mrigangha 2026-05-07 12:37:38 +00:00
parent 326db4ec7c
commit 0edefaa4c1
2 changed files with 90 additions and 89 deletions

View file

@ -6,11 +6,13 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"net"
"net/http" "net/http"
"os" "os"
"path/filepath" "path/filepath"
"sync" "sync"
"time" "time"
"strconv"
"github.com/sipeed/picoclaw/pkg/config" "github.com/sipeed/picoclaw/pkg/config"
"github.com/sipeed/picoclaw/pkg/logger" "github.com/sipeed/picoclaw/pkg/logger"
@ -50,7 +52,7 @@ func generateToken() string {
// then verifies the reported PID matches expectedPID to confirm the process // then verifies the reported PID matches expectedPID to confirm the process
// is actually a picoclaw gateway and not a foreign service on the same port. // is actually a picoclaw gateway and not a foreign service on the same port.
func isGatewayAlive(host string, port int, expectedPID int) bool { func isGatewayAlive(host string, port int, expectedPID int) bool {
url := fmt.Sprintf("http://%s:%d/health", host, port) url := "http://" + net.JoinHostPort(host, strconv.Itoa(port)) + "/health"
client := &http.Client{Timeout: 2 * time.Second} client := &http.Client{Timeout: 2 * time.Second}
resp, err := client.Get(url) resp, err := client.Get(url)
if err != nil { if err != nil {

View file

@ -124,7 +124,6 @@ func TestWritePidFileNonLocalhostHost(t *testing.T) {
} }
} }
// verifies that a foreign process reusing a crashed gateway's PID is treated as stale. // verifies that a foreign process reusing a crashed gateway's PID is treated as stale.
func TestWritePidFileForeignPIDReuse(t *testing.T) { func TestWritePidFileForeignPIDReuse(t *testing.T) {
dir := tmpDir(t) dir := tmpDir(t)