Example #1
0
// create and start a service, create a client
// download fixture modules if they aren't present
func (s *ComponentTestSuite) SetUpSuite(c *C) {
	s.path = "./tmp-test"

	os.MkdirAll(s.path+"/modules", 0755)
	if _, err := os.Stat(s.path + "/puppetlabs-apache-1.5.0.tar.gz"); err != nil {
		dl("https://forgeapi.puppetlabs.com/v3/files/puppetlabs-apache-1.5.0.tar.gz", s.path+"/puppetlabs-apache-1.5.0.tar.gz")
		dl("https://forgeapi.puppetlabs.com/v3/files/puppetlabs-concat-1.2.3.tar.gz", s.path+"/puppetlabs-concat-1.2.3.tar.gz")
		dl("https://forgeapi.puppetlabs.com/v3/files/puppetlabs-stdlib-4.6.0.tar.gz", s.path+"/puppetlabs-stdlib-4.6.0.tar.gz")
	}

	s.port = Port()
	s.svc = service.New(strconv.Itoa(s.port), s.path+"/modules")
	s.client = &api.AnvilClient{Address: fmt.Sprintf("localhost:%d", s.port)}

	go s.svc.Run()
}
Example #2
0
func main() {
	port := os.Getenv("PORT")
	modulePath := os.Getenv("MODULEPATH")

	if len(port) == 0 {
		log.Fatal("Missing PORT environment variable")
	}
	if len(modulePath) == 0 {
		log.Fatal("Missing MODULEPATH environment variable")
	}

	svc := service.New(port, modulePath)

	if err := svc.Run(); err != nil {
		log.Print(err)
	}
}