fix: Auto-sync RPC client/server versions from CLI version
- Set rpc.ServerVersion from Version in daemon startup - Set rpc.ClientVersion from Version in main.go startup - Eliminates need to manually update RPC versions - Both now use 0.0.0 placeholder, overridden at runtime Amp-Thread-ID: https://ampcode.com/threads/T-03c37f7f-f41e-4b87-8700-d346c21bad30 Co-authored-by: Amp <amp@ampcode.com>
This commit is contained in:
@@ -858,6 +858,9 @@ func setupDaemonLock(pidFile string, global bool, log daemonLogger) (io.Closer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func startRPCServer(ctx context.Context, socketPath string, store storage.Storage, log daemonLogger) (*rpc.Server, chan error, error) {
|
func startRPCServer(ctx context.Context, socketPath string, store storage.Storage, log daemonLogger) (*rpc.Server, chan error, error) {
|
||||||
|
// Sync daemon version with CLI version
|
||||||
|
rpc.ServerVersion = Version
|
||||||
|
|
||||||
server := rpc.NewServer(socketPath, store)
|
server := rpc.NewServer(socketPath, store)
|
||||||
serverErrChan := make(chan error, 1)
|
serverErrChan := make(chan error, 1)
|
||||||
|
|
||||||
|
|||||||
@@ -123,6 +123,9 @@ var rootCmd = &cobra.Command{
|
|||||||
noAutoImport = true
|
noAutoImport = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sync RPC client version with CLI version
|
||||||
|
rpc.ClientVersion = Version
|
||||||
|
|
||||||
// Set auto-flush based on flag (invert no-auto-flush)
|
// Set auto-flush based on flag (invert no-auto-flush)
|
||||||
autoFlushEnabled = !noAutoFlush
|
autoFlushEnabled = !noAutoFlush
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,8 @@ import (
|
|||||||
|
|
||||||
// ClientVersion is the version of this RPC client
|
// ClientVersion is the version of this RPC client
|
||||||
// This should match the bd CLI version for proper compatibility checks
|
// This should match the bd CLI version for proper compatibility checks
|
||||||
var ClientVersion = "0.9.10"
|
// It's set dynamically by main.go from cmd/bd/version.go before making RPC calls
|
||||||
|
var ClientVersion = "0.0.0" // Placeholder; overridden at startup
|
||||||
|
|
||||||
// Client represents an RPC client that connects to the daemon
|
// Client represents an RPC client that connects to the daemon
|
||||||
type Client struct {
|
type Client struct {
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ import (
|
|||||||
|
|
||||||
// ServerVersion is the version of this RPC server
|
// ServerVersion is the version of this RPC server
|
||||||
// This should match the bd CLI version for proper compatibility checks
|
// This should match the bd CLI version for proper compatibility checks
|
||||||
// It's set as a var so it can be initialized from main
|
// It's set dynamically by daemon.go from cmd/bd/version.go before starting the server
|
||||||
var ServerVersion = "0.9.10"
|
var ServerVersion = "0.0.0" // Placeholder; overridden by daemon startup
|
||||||
|
|
||||||
const (
|
const (
|
||||||
statusUnhealthy = "unhealthy"
|
statusUnhealthy = "unhealthy"
|
||||||
|
|||||||
Reference in New Issue
Block a user