func getSerialisedInstance( app, proc string, id int64, status InsStatus, sp cp.Snapshot, ) (*Instance, error) { var ( i = &Instance{ ID: id, AppName: app, ProcessName: proc, dir: cp.NewDir(instancePath(id), sp), } c = &cp.JsonCodec{ DecodedVal: i, } ) _, err := sp.GetFile(i.procStatusPath(status), c) if err != nil { return nil, errorf(err, "fetching instance %d: %s", id, err) } return i, nil }
func claimNextPort(s cp.Snapshot) (int, error) { for { var err error s, err = s.FastForward() if err != nil { return -1, err } f, err := s.GetFile(nextPortPath, new(cp.IntCodec)) if err == nil { port := f.Value.(int) f, err = f.Set(port + 1) if err == nil { return port, nil } time.Sleep(time.Second / 10) } else { return -1, err } } }