LEFT | RIGHT |
1 package main | 1 package main |
2 | 2 |
3 import ( | 3 import ( |
4 "fmt" | 4 "fmt" |
5 "launchpad.net/gnuflag" | 5 "launchpad.net/gnuflag" |
6 "launchpad.net/juju-core/charm" | 6 "launchpad.net/juju-core/charm" |
7 "launchpad.net/juju-core/cmd" | 7 "launchpad.net/juju-core/cmd" |
8 "launchpad.net/juju-core/environs/agent" | 8 "launchpad.net/juju-core/environs/agent" |
9 "launchpad.net/juju-core/log" | 9 "launchpad.net/juju-core/log" |
10 "launchpad.net/juju-core/state" | 10 "launchpad.net/juju-core/state" |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 } | 50 } |
51 | 51 |
52 // Stop stops the machine agent. | 52 // Stop stops the machine agent. |
53 func (a *MachineAgent) Stop() error { | 53 func (a *MachineAgent) Stop() error { |
54 a.tomb.Kill(nil) | 54 a.tomb.Kill(nil) |
55 return a.tomb.Wait() | 55 return a.tomb.Wait() |
56 } | 56 } |
57 | 57 |
58 // Run runs a machine agent. | 58 // Run runs a machine agent. |
59 func (a *MachineAgent) Run(_ *cmd.Context) error { | 59 func (a *MachineAgent) Run(_ *cmd.Context) error { |
60 defer log.Noticef("machine agent exiting") | |
61 if err := a.Conf.read(state.MachineTag(a.MachineId)); err != nil { | 60 if err := a.Conf.read(state.MachineTag(a.MachineId)); err != nil { |
62 return err | 61 return err |
63 } | 62 } |
64 charm.CacheDir = filepath.Join(a.Conf.DataDir, "charmcache") | 63 charm.CacheDir = filepath.Join(a.Conf.DataDir, "charmcache") |
65 defer a.tomb.Done() | 64 defer a.tomb.Done() |
66 | 65 |
67 // We run the API server worker first, because we may | 66 // We run the API server worker first, because we may |
68 // need to connect to it before starting the other workers. | 67 // need to connect to it before starting the other workers. |
69 apiDone := make(chan error) | 68 apiDone := make(chan error) |
70 // Pass a copy of the API configuration to maybeRunAPIServer | 69 // Pass a copy of the API configuration to maybeRunAPIServer |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 if err != nil { | 194 if err != nil { |
196 return err | 195 return err |
197 } | 196 } |
198 select { | 197 select { |
199 case <-a.tomb.Dying(): | 198 case <-a.tomb.Dying(): |
200 case <-srv.Dead(): | 199 case <-srv.Dead(): |
201 log.Noticef("API server has died: %v", srv.Stop()) | 200 log.Noticef("API server has died: %v", srv.Stop()) |
202 } | 201 } |
203 return srv.Stop() | 202 return srv.Stop() |
204 } | 203 } |
LEFT | RIGHT |