MCPcopy Create free account
hub / github.com/danderson/netboot / Serve

Method Serve

pixiecore/pixiecore.go:202–266  ·  view source on GitHub ↗

Serve listens for machines attempting to boot, and uses Booter to help them.

()

Source from the content-addressed store, hash-verified

200// Serve listens for machines attempting to boot, and uses Booter to
201// help them.
202func (s *Server) Serve() error {
203 if s.DHCPPort == 0 {
204 s.DHCPPort = portDHCP
205 }
206 if s.TFTPPort == 0 {
207 s.TFTPPort = portTFTP
208 }
209 if s.PXEPort == 0 {
210 s.PXEPort = portPXE
211 }
212 if s.HTTPPort == 0 {
213 s.HTTPPort = portHTTP
214 }
215
216 newDHCP := dhcp4.NewConn
217 if s.DHCPNoBind {
218 newDHCP = dhcp4.NewSnooperConn
219 }
220
221 dhcp, err := newDHCP(fmt.Sprintf("%s:%d", s.Address, s.DHCPPort))
222 if err != nil {
223 return err
224 }
225 tftp, err := net.ListenPacket("udp", fmt.Sprintf("%s:%d", s.Address, s.TFTPPort))
226 if err != nil {
227 dhcp.Close()
228 return err
229 }
230 pxe, err := net.ListenPacket("udp4", fmt.Sprintf("%s:%d", s.Address, s.PXEPort))
231 if err != nil {
232 dhcp.Close()
233 tftp.Close()
234 return err
235 }
236 http, err := net.Listen("tcp", fmt.Sprintf("%s:%d", s.Address, s.HTTPPort))
237 if err != nil {
238 dhcp.Close()
239 tftp.Close()
240 pxe.Close()
241 return err
242 }
243
244 s.events = make(map[string][]machineEvent)
245 // 5 buffer slots, one for each goroutine, plus one for
246 // Shutdown(). We only ever pull the first error out, but shutdown
247 // will likely generate some spurious errors from the other
248 // goroutines, and we want them to be able to dump them without
249 // blocking.
250 s.errs = make(chan error, 6)
251
252 s.debug("Init", "Starting Pixiecore goroutines")
253
254 go func() { s.errs <- s.serveDHCP(dhcp) }()
255 go func() { s.errs <- s.servePXE(pxe) }()
256 go func() { s.errs <- s.serveTFTP(tftp) }()
257 go func() { s.errs <- serveHTTP(http, s.serveHTTP) }()
258
259 // Wait for either a fatal error, or Shutdown().

Callers 15

serveTFTPMethod · 0.95
v1compatCLIFunction · 0.95
TestAPIBooterFunction · 0.45
serveHTTPFunction · 0.45
debianRecipeFunction · 0.45
ubuntuRecipeFunction · 0.45
fedoraRecipeFunction · 0.45
centosRecipeFunction · 0.45
coreosRecipeFunction · 0.45
netbootRecipeFunction · 0.45
archRecipeFunction · 0.45
bootcmd.goFile · 0.45

Calls 6

debugMethod · 0.95
serveDHCPMethod · 0.95
servePXEMethod · 0.95
serveTFTPMethod · 0.95
serveHTTPFunction · 0.85
CloseMethod · 0.45

Tested by 1

TestAPIBooterFunction · 0.36