本文整理汇总了Golang中github.com/docker/docker/pkg/reexec.Register函数的典型用法代码示例。如果您正苦于以下问题:Golang Register函数的具体用法?Golang Register怎么用?Golang Register使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Register函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: init
func init() {
reexec.Register("namespaced", namespaced)
if reexec.Init() {
os.Exit(0)
}
}
示例2: TestMain
func TestMain(m *testing.M) {
reexec.Register("enqueue", reexecEnqueue)
if reexec.Init() {
return
}
os.Exit(m.Run())
}
示例3: init
func init() {
reexec.Register("chrootwrite", func() {
var rootfs, path string
var uid, gid int
flag.StringVar(&rootfs, "rootfs", "", "rootfs")
flag.StringVar(&path, "path", "", "path")
flag.IntVar(&uid, "uid", 0, "uid")
flag.IntVar(&gid, "gid", 0, "gid")
flag.Parse()
if err := syscall.Chroot(rootfs); err != nil {
panic(err)
}
if err := os.Chdir("/"); err != nil {
panic(err)
}
var contents bytes.Buffer
if _, err := io.Copy(&contents, os.Stdin); err != nil {
panic(err)
}
w := RootfsWriter{}
if err := w.writeFile(lager.NewLogger("chroot-write"), path, contents.Bytes(), rootfs, uid, gid); err != nil {
panic(err)
}
})
}
示例4: TestMain
func TestMain(m *testing.M) {
reexec.Register("allocate", allocate)
if reexec.Init() {
return
}
os.Exit(m.Run())
}
示例5: registerCmd
func registerCmd(cmd string, mainFunc func()) {
log.Debugf("Registering main %s", cmd)
reexec.Register(cmd, mainFunc)
parts := strings.Split(cmd, "/")
if len(parts) == 0 {
return
}
last := parts[len(parts)-1]
log.Debugf("Registering main %s", last)
reexec.Register(last, mainFunc)
log.Debugf("Registering main %s", "./"+last)
reexec.Register("./"+last, mainFunc)
}
示例6: init
// init registers the windows graph drivers to the register.
func init() {
graphdriver.Register("windowsfilter", InitFilter)
// DOCKER_WINDOWSFILTER_NOREEXEC allows for inline processing which makes
// debugging issues in the re-exec codepath significantly easier.
if os.Getenv("DOCKER_WINDOWSFILTER_NOREEXEC") != "" {
logrus.Warnf("WindowsGraphDriver is set to not re-exec. This is intended for debugging purposes only.")
noreexec = true
} else {
reexec.Register("docker-windows-write-layer", writeLayerReexec)
}
}
示例7: main
func main() {
registerCmd("/init", osInit.MainInit)
registerCmd(config.SYSINIT_BIN, sysinit.Main)
registerCmd("/usr/bin/dockerlaunch", dockerlaunch.Main)
registerCmd("/usr/bin/user-docker", userdocker.Main)
registerCmd("/usr/bin/system-docker", systemdocker.Main)
registerCmd("/sbin/poweroff", power.PowerOff)
registerCmd("/sbin/reboot", power.Reboot)
registerCmd("/sbin/halt", power.Halt)
registerCmd("/sbin/shutdown", power.Main)
registerCmd("/usr/bin/respawn", respawn.Main)
registerCmd("/usr/bin/ros", control.Main)
registerCmd("/usr/bin/cloud-init", cloudinit.Main)
registerCmd("/usr/sbin/netconf", network.Main)
registerCmd("/usr/sbin/wait-for-network", waitfornetwork.Main)
registerCmd("/usr/sbin/wait-for-docker", wait.Main)
if !reexec.Init() {
reexec.Register(os.Args[0], control.Main)
if !reexec.Init() {
log.Fatalf("Failed to find an entry point for %s", os.Args[0])
}
}
}
示例8: init
func init() {
reexec.Register("configure-container-netns", func() {
var netNsPath, containerIntf, containerIPStr, bridgeIPStr, subnetStr string
var mtu int
flag.StringVar(&netNsPath, "netNsPath", "", "netNsPath")
flag.StringVar(&containerIntf, "containerIntf", "", "containerIntf")
flag.StringVar(&containerIPStr, "containerIP", "", "containerIP")
flag.StringVar(&bridgeIPStr, "bridgeIP", "", "bridgeIP")
flag.StringVar(&subnetStr, "subnet", "", "subnet")
flag.IntVar(&mtu, "mtu", 0, "mtu")
flag.Parse()
fd, err := os.Open(netNsPath)
if err != nil {
fmt.Fprintf(os.Stderr, "opening netns `%s`: %s", netNsPath, err)
os.Exit(1)
}
defer fd.Close()
netNsExecer := &netns.Execer{}
if err = netNsExecer.Exec(fd, func() error {
containerIP := net.ParseIP(containerIPStr)
bridgeIP := net.ParseIP(bridgeIPStr)
_, subnetIPNet, err := net.ParseCIDR(subnetStr)
if err != nil {
panic(err)
}
link := devices.Link{}
intf, found, err := link.InterfaceByName(containerIntf)
if err != nil {
panic(err)
}
if !found {
return fmt.Errorf("interface `%s` was not found", containerIntf)
}
if err := link.AddIP(intf, containerIP, subnetIPNet); err != nil {
panic(err)
}
if err := link.SetUp(intf); err != nil {
panic(err)
}
if err := link.AddDefaultGW(intf, bridgeIP); err != nil {
panic(err)
}
if err := link.SetMTU(intf, mtu); err != nil {
panic(err)
}
return nil
}); err != nil {
fmt.Fprintf(os.Stderr, err.Error())
os.Exit(1)
}
})
}
示例9: init
func init() {
reexec.Register("fwmarker", fwMarker)
reexec.Register("redirecter", redirecter)
}
示例10: init
func init() {
reexec.Register("set-ipv6", reexecSetIPv6)
}
示例11: init
func init() {
reexec.Register(name, prepare)
}
示例12: init
func init() {
reexec.Register(dockerMonitor, execMonitor)
}
示例13: init
func init() {
reexec.Register("initd", start)
}
示例14: init
func init() {
reexec.Register("containerd-nslistener", setupNsListener)
}
示例15: init
// init registers the windows graph drivers to the register.
func init() {
graphdriver.Register("windowsfilter", InitFilter)
reexec.Register("docker-windows-write-layer", writeLayer)
}