You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package main
import (
"fmt"
"os"
"os/exec"
"syscall"
"github.com/ftrvxmtrx/fd"
)
func main() {
// Existing GoBGP process logic...
// When ready to upgrade:
err := upgradeGoBGP()
if err != nil {
fmt.Println("Error upgrading GoBGP:", err)
}
}
func upgradeGoBGP() error {
// Create a new process for the upgraded GoBGP
cmd := exec.Command("./gobgp", "daemon") // Adjust command as necessary
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
// Pass existing file descriptors to the new process
oldFDs := []int{ /* add your file descriptors here */ }
newFDs, err := fd.New(oldFDs)
if err != nil {
return fmt.Errorf("failed to create file descriptor set: %w", err)
}
// Start the new GoBGP process
if err := cmd.Start(); err != nil {
return fmt.Errorf("failed to start new GoBGP process: %w", err)
}
// Pass file descriptors to the new process
if err := newFDs.PassTo(cmd.Process.Pid); err != nil {
return fmt.Errorf("failed to pass file descriptors: %w", err)
}
// Optionally wait for the new process to finish
// If you want to wait, use cmd.Wait()
return nil
}
// Function to request a RIB refresh
func requestRIBRefresh() {
// Implementation for requesting RIB refresh
// This may involve calling an appropriate method or sending a signal
fmt.Println("Requesting RIB refresh...")
}
Consider looking at passing file descriptors between old and new gobgp processes?
https://godoc.org/github.com/ftrvxmtrx/fd
This would allow you to upgrade gobgp daemon 'live'.
Presumably we'd need to request a rib refresh right away, but the connection wouldn't go down.
(important for some with BGP)
The text was updated successfully, but these errors were encountered: