mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-10-06 06:39:07 +00:00
feat: improve dev-local bootstrap behavior and add client defaults logging
This commit is contained in:
parent
cf36d301d5
commit
fbfea68f02
@ -520,6 +520,7 @@ Notes:
|
||||
- With `NETWORK_DEV_LOCAL`, `client.DefaultDatabaseEndpoints()` returns `http://127.0.0.1:$RQLITE_PORT`.
|
||||
- `client.DefaultBootstrapPeers()` returns `LOCAL_BOOTSTRAP_MULTIADDR` if set, otherwise `/ip4/127.0.0.1/tcp/4001`.
|
||||
- If you construct config via `client.DefaultClientConfig(...)`, DB endpoints are pinned to localhost and will override `RQLITE_NODES` automatically.
|
||||
- When `NETWORK_DEV_LOCAL` is set and `LOCAL_BOOTSTRAP_MULTIADDR` is NOT set, the client attempts to auto-load the local bootstrap multiaddr (with peer ID) from `./data/bootstrap/peer.info` (or `LOCAL_BOOTSTRAP_INFO` path if provided). Only if no file is found does it fall back to `/ip4/127.0.0.1/tcp/4001`.
|
||||
|
||||
### Migration Guide for Apps (e.g., anchat)
|
||||
|
||||
|
@ -75,9 +75,9 @@ func MapFlagsAndEnvToConfig(cfg *config.Config, fv NodeFlagValues, isBootstrap b
|
||||
if devLocal {
|
||||
// In dev-local, run a primary bootstrap locally
|
||||
cfg.Database.RQLiteJoinAddress = ""
|
||||
// Also prefer localhost bootstrap peers for any consumers reading cfg
|
||||
cfg.Discovery.BootstrapPeers = client.DefaultBootstrapPeers()
|
||||
logger.Printf("Dev-local: Primary bootstrap node - localhost defaults enabled")
|
||||
// Do not set bootstrap peers to avoid including self; clients can still
|
||||
// derive DB endpoints via DefaultDatabaseEndpoints in dev-local.
|
||||
logger.Printf("Dev-local: Primary bootstrap node - localhost defaults enabled (no bootstrap peers set to avoid self)")
|
||||
return ""
|
||||
}
|
||||
bootstrapPeers := constants.GetBootstrapPeers()
|
||||
|
@ -17,6 +17,7 @@ import (
|
||||
"git.debros.io/DeBros/network/pkg/constants"
|
||||
"git.debros.io/DeBros/network/pkg/logging"
|
||||
"git.debros.io/DeBros/network/pkg/node"
|
||||
"git.debros.io/DeBros/network/pkg/client"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@ -112,6 +113,19 @@ func main() {
|
||||
logger.Printf("RQLite HTTP port: %d", cfg.Database.RQLitePort)
|
||||
logger.Printf("RQLite Raft port: %d", cfg.Database.RQLiteRaftPort)
|
||||
|
||||
// For development visibility, print what the CLIENT library will return by default
|
||||
clientBootstrap := client.DefaultBootstrapPeers()
|
||||
clientDB := client.DefaultDatabaseEndpoints()
|
||||
logger.Printf("[Client Defaults] Bootstrap peers: %v", clientBootstrap)
|
||||
logger.Printf("[Client Defaults] Database endpoints: %v", clientDB)
|
||||
// Also show node-configured values
|
||||
logger.Printf("[Node Config] Bootstrap peers: %v", cfg.Discovery.BootstrapPeers)
|
||||
if cfg.Database.RQLiteJoinAddress != "" {
|
||||
logger.Printf("[Node Config] RQLite Raft join: %s", cfg.Database.RQLiteJoinAddress)
|
||||
} else if isBootstrap {
|
||||
logger.Printf("[Node Config] Bootstrap node: starting new RQLite cluster (no join)")
|
||||
}
|
||||
|
||||
// Create context for graceful shutdown
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
Loading…
x
Reference in New Issue
Block a user