mirror of
https://github.com/DeBrosOfficial/network.git
synced 2025-10-06 12:09:07 +00:00
Fix RQLite join address validation and improve error handling
- Replace hardcoded fallback IP with localhost for better compatibility - Add join address format validation - Improve logging for better troubleshooting - Add detailed RQLite startup logging with full args
This commit is contained in:
parent
79efd7b2c5
commit
e6a305a8a7
@ -119,8 +119,10 @@ func main() {
|
||||
bootstrapHost := parseHostFromMultiaddr(*bootstrap)
|
||||
if bootstrapHost != "" {
|
||||
rqliteJoinAddr = fmt.Sprintf("http://%s:4001", bootstrapHost)
|
||||
logger.Printf("Using extracted bootstrap host %s for RQLite join", bootstrapHost)
|
||||
} else {
|
||||
rqliteJoinAddr = "http://57.129.81.31:4001" // Default fallback
|
||||
logger.Printf("Warning: Could not extract host from bootstrap peer %s, using localhost fallback", *bootstrap)
|
||||
rqliteJoinAddr = "http://localhost:4001" // Use localhost fallback instead
|
||||
}
|
||||
logger.Printf("Using command line bootstrap peer: %s", *bootstrap)
|
||||
} else {
|
||||
@ -132,13 +134,18 @@ func main() {
|
||||
bootstrapHost := parseHostFromMultiaddr(bootstrapPeers[0])
|
||||
if bootstrapHost != "" {
|
||||
rqliteJoinAddr = fmt.Sprintf("http://%s:4001", bootstrapHost)
|
||||
logger.Printf("Using extracted bootstrap host %s for RQLite join", bootstrapHost)
|
||||
} else {
|
||||
rqliteJoinAddr = "http://57.129.81.31:4001" // Default fallback
|
||||
logger.Printf("Warning: Could not extract host from bootstrap peer %s", bootstrapPeers[0])
|
||||
// Try primary production server as fallback
|
||||
rqliteJoinAddr = "http://localhost:4001"
|
||||
}
|
||||
logger.Printf("Using environment bootstrap peers: %v", bootstrapPeers)
|
||||
} else {
|
||||
logger.Printf("Warning: No bootstrap peers configured")
|
||||
rqliteJoinAddr = "http://57.129.81.31:4001" // Default fallback
|
||||
// Default to localhost when no peers configured
|
||||
rqliteJoinAddr = "http://localhost:4001"
|
||||
logger.Printf("Using localhost fallback for RQLite join")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -43,12 +43,13 @@ func (r *RQLiteManager) Start(ctx context.Context) error {
|
||||
return fmt.Errorf("failed to create RQLite data directory: %w", err)
|
||||
}
|
||||
|
||||
// Get the external IP address for advertising
|
||||
// Get the external IP address for advertising
|
||||
externalIP, err := r.getExternalIP()
|
||||
if err != nil {
|
||||
r.logger.Warn("Failed to get external IP, using localhost", zap.Error(err))
|
||||
externalIP = "localhost"
|
||||
}
|
||||
r.logger.Info("Using external IP for RQLite advertising", zap.String("ip", externalIP))
|
||||
|
||||
// Build RQLite command
|
||||
args := []string{
|
||||
@ -64,7 +65,17 @@ func (r *RQLiteManager) Start(ctx context.Context) error {
|
||||
|
||||
// Add join address if specified (for non-bootstrap or secondary bootstrap nodes)
|
||||
if r.config.RQLiteJoinAddress != "" {
|
||||
args = append(args, "-join", r.config.RQLiteJoinAddress)
|
||||
r.logger.Info("Joining RQLite cluster", zap.String("join_address", r.config.RQLiteJoinAddress))
|
||||
|
||||
// Validate join address format before using it
|
||||
if strings.HasPrefix(r.config.RQLiteJoinAddress, "http://") {
|
||||
args = append(args, "-join", r.config.RQLiteJoinAddress)
|
||||
} else {
|
||||
r.logger.Warn("Invalid join address format, skipping join", zap.String("address", r.config.RQLiteJoinAddress))
|
||||
return fmt.Errorf("invalid RQLite join address format: %s (must start with http://)", r.config.RQLiteJoinAddress)
|
||||
}
|
||||
} else {
|
||||
r.logger.Info("No join address specified - starting as new cluster")
|
||||
}
|
||||
|
||||
// Add data directory as positional argument
|
||||
@ -75,6 +86,8 @@ func (r *RQLiteManager) Start(ctx context.Context) error {
|
||||
zap.Int("http_port", r.config.RQLitePort),
|
||||
zap.Int("raft_port", r.config.RQLiteRaftPort),
|
||||
zap.String("join_address", r.config.RQLiteJoinAddress),
|
||||
zap.String("external_ip", externalIP),
|
||||
zap.Strings("full_args", args),
|
||||
)
|
||||
|
||||
// Start RQLite process
|
||||
|
Loading…
x
Reference in New Issue
Block a user