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


Golang Controller.WriteConsulConfig方法代碼示例

本文整理匯總了Golang中confab.Controller.WriteConsulConfig方法的典型用法代碼示例。如果您正苦於以下問題:Golang Controller.WriteConsulConfig方法的具體用法?Golang Controller.WriteConsulConfig怎麽用?Golang Controller.WriteConsulConfig使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在confab.Controller的用法示例。


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

示例1: start

func start(flagSet *flag.FlagSet, path string, controller confab.Controller, agentClient *agent.Client) {
	timeout := confab.NewTimeout(time.After(time.Duration(controller.Config.Confab.TimeoutInSeconds) * time.Second))

	_, err := os.Stat(controller.Config.Path.ConsulConfigDir)
	if err != nil {
		printUsageAndExit(fmt.Sprintf("\"consul_config_dir\" %q could not be found",
			controller.Config.Path.ConsulConfigDir), flagSet)
	}

	if len(agentClient.ExpectedMembers) == 0 {
		printUsageAndExit("at least one \"expected-member\" must be provided", flagSet)
	}

	err = controller.WriteConsulConfig()
	if err != nil {
		stderr.Printf("error writing consul config file: %s", err)
		os.Exit(1)
	}

	err = controller.WriteServiceDefinitions()
	if err != nil {
		stderr.Printf("error writing service definitions: %s", err)
		os.Exit(1)
	}

	err = controller.BootAgent(timeout)
	if err != nil {
		stderr.Printf("error booting consul agent: %s", err)
		exit(controller, 1)
	}

	if controller.Config.Consul.Agent.Mode == "server" {
		configureServer(controller, agentClient, timeout)
	} else {
		configureClient(controller)
	}
}
開發者ID:tkysk,項目名稱:consul-release,代碼行數:37,代碼來源:main.go

示例2:

		}
	})

	Describe("WriteConsulConfig", func() {
		var configDir string

		BeforeEach(func() {
			var err error
			configDir, err = ioutil.TempDir("", "")
			Expect(err).NotTo(HaveOccurred())

			controller.Config.Path.ConsulConfigDir = configDir
		})

		It("writes a config file to the consul_config dir", func() {
			err := controller.WriteConsulConfig()
			Expect(err).NotTo(HaveOccurred())

			buf, err := ioutil.ReadFile(filepath.Join(configDir, "config.json"))
			Expect(err).NotTo(HaveOccurred())
			Expect(buf).To(MatchJSON(`{
				"server": false,
				"domain": "cf.internal",
				"datacenter": "",
				"data_dir": "/var/vcap/store/consul_agent",
				"log_level": "",
				"node_name": "node-0",
				"ports": {
					"dns": 53
				},
				"rejoin_after_leave": true,
開發者ID:tkysk,項目名稱:consul-release,代碼行數:31,代碼來源:controller_test.go


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