MCPcopy Create free account
hub / github.com/convox/rack / Start

Method Start

pkg/sync/sync.go:84–132  ·  view source on GitHub ↗
(st Stream)

Source from the content-addressed store, hash-verified

82}
83
84func (s *Sync) Start(st Stream) error {
85 s.waitForContainer()
86
87 if !filepath.IsAbs(s.Remote) {
88 wdb, err := Docker("inspect", "--format", "'{{.Config.WorkingDir}}'", s.Container).Output()
89 if err != nil {
90 return err
91 }
92
93 swdb := string(wdb)
94 swdb = strings.TrimSpace(swdb)
95 swdb = strings.TrimPrefix(swdb, "'")
96 swdb = strings.TrimSuffix(swdb, "'")
97
98 s.Remote = filepath.Join(swdb, s.Remote)
99 }
100
101 go s.watchIncoming(st)
102 go s.watchOutgoing(st)
103
104 incoming := []changes.Change{}
105 outgoing := []changes.Change{}
106
107 tick := time.Tick(1 * time.Second)
108
109 for {
110 select {
111 case c := <-s.incoming:
112 incoming = append(incoming, c)
113 case c := <-s.outgoing:
114 outgoing = append(outgoing, c)
115 case <-tick:
116 if len(incoming) > 0 {
117 a, r := changes.Partition(incoming)
118 s.syncIncomingAdds(a, st)
119 s.syncIncomingRemoves(r, st)
120 incoming = []changes.Change{}
121 }
122 if len(outgoing) > 0 {
123 a, r := changes.Partition(outgoing)
124 s.syncOutgoingAdds(a, st)
125 s.syncOutgoingRemoves(r, st)
126 outgoing = []changes.Change{}
127 }
128 }
129 }
130
131 return nil
132}
133
134func (s *Sync) syncIncomingAdds(adds []changes.Change, st Stream) {
135 if len(adds) == 0 {

Callers 15

Start1Method · 0.45
execFunction · 0.45
stackResourceMethod · 0.45
loggerMethod · 0.45
RegistryAddMethod · 0.45
RegistryRemoveMethod · 0.45
RegistryListMethod · 0.45
CapacityGetMethod · 0.45
BuildCreateMethod · 0.45
BuildExportMethod · 0.45
BuildImportMethod · 0.45
runBuildMethod · 0.45

Calls 7

waitForContainerMethod · 0.95
watchIncomingMethod · 0.95
watchOutgoingMethod · 0.95
syncIncomingAddsMethod · 0.95
syncIncomingRemovesMethod · 0.95
syncOutgoingAddsMethod · 0.95
syncOutgoingRemovesMethod · 0.95

Tested by

no test coverage detected