當前位置: 首頁>>代碼示例>>Golang>>正文


Golang systemd.SdNotify函數代碼示例

本文整理匯總了Golang中github.com/dotcloud/docker/pkg/systemd.SdNotify函數的典型用法代碼示例。如果您正苦於以下問題:Golang SdNotify函數的具體用法?Golang SdNotify怎麽用?Golang SdNotify使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了SdNotify函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: AcceptConnections

func AcceptConnections(job *engine.Job) engine.Status {
	// Tell the init daemon we are accepting requests
	go systemd.SdNotify("READY=1")

	// close the lock so the listeners start accepting connections
	close(activationLock)

	return engine.StatusOK
}
開發者ID:kraman,項目名稱:docker,代碼行數:9,代碼來源:server.go

示例2: ListenAndServe

func ListenAndServe(proto, addr string, srv *Server, logging bool) error {
	r, err := createRouter(srv, logging)
	if err != nil {
		return err
	}
	l, e := net.Listen(proto, addr)
	if e != nil {
		return e
	}
	if proto == "unix" {
		if err := os.Chmod(addr, 0660); err != nil {
			return err
		}

		groups, err := ioutil.ReadFile("/etc/group")
		if err != nil {
			return err
		}
		re := regexp.MustCompile("(^|\n)docker:.*?:([0-9]+)")
		if gidMatch := re.FindStringSubmatch(string(groups)); gidMatch != nil {
			gid, err := strconv.Atoi(gidMatch[2])
			if err != nil {
				return err
			}
			utils.Debugf("docker group found. gid: %d", gid)
			if err := os.Chown(addr, 0, gid); err != nil {
				return err
			}
		}
	}
	httpSrv := http.Server{Addr: addr, Handler: r}

	log.Printf("Listening for HTTP on %s (%s)\n", addr, proto)
	// Tell the init daemon we are accepting requests
	go systemd.SdNotify("READY=1")
	return httpSrv.Serve(l)
}
開發者ID:krast,項目名稱:docker,代碼行數:37,代碼來源:api.go

示例3: ServeApi

// ServeApi loops through all of the protocols sent in to docker and spawns
// off a go routine to setup a serving http.Server for each.
func ServeApi(job *engine.Job) engine.Status {
	protoAddrs := job.Args
	chErrors := make(chan error, len(protoAddrs))

	for _, protoAddr := range protoAddrs {
		protoAddrParts := strings.SplitN(protoAddr, "://", 2)
		go func() {
			log.Printf("Listening for HTTP on %s (%s)\n", protoAddrParts[0], protoAddrParts[1])
			chErrors <- ListenAndServe(protoAddrParts[0], protoAddrParts[1], job.Eng, job.GetenvBool("Logging"), job.GetenvBool("EnableCors"), job.Getenv("Version"))
		}()
	}

	for i := 0; i < len(protoAddrs); i += 1 {
		err := <-chErrors
		if err != nil {
			return job.Error(err)
		}
	}

	// Tell the init daemon we are accepting requests
	go systemd.SdNotify("READY=1")

	return engine.StatusOK
}
開發者ID:jpoimboe,項目名稱:docker,代碼行數:26,代碼來源:api.go


注:本文中的github.com/dotcloud/docker/pkg/systemd.SdNotify函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。