~dave-cheney/juju-core/153-fix-release-tools-script

« back to all changes in this revision

Viewing changes to upstart/upstart.go

  • Committer: Tarmac
  • Author(s): Andrew Wilkins
  • Date: 2013-08-30 01:48:39 UTC
  • mfrom: (1628.11.22 juju-add-machine)
  • Revision ID: tarmac-20130830014839-infsllif52ywy6yq
[r=axwalk] Update add-machine for manual provisioning

juju add-machine is updated to use a new package,
environs/manual, to manually provision tools and
a machine agent to an existing machine.

When a manually provisioned machine is destroyed
via juju destroy-machine, the machine agent will
detect its termination and remove its upstart
configuration file. There is currently no cleanup
of the data or log directories; this will be done
in a follow-up pending discussion.

When the machine goes to Dead, a provisioner will
remove the machine from state just like any other
machine.

TODO: destroy-environment will currently leak
manually provisioned machines. A follow-up will
address this by requiring users to individually
destroy-machine before destroy-environment will
proceed. Alternatively (or perhaps additionally),
destroy-environment may take a flag to automatically
do this.

https://codereview.appspot.com/12831043/

Show diffs side-by-side

added added

removed removed

Lines of Context:
77
77
        return runCommand("stop", s.Name)
78
78
}
79
79
 
 
80
// StopAndRemove stops the service and then deletes the service
 
81
// configuration from the init directory.
 
82
func (s *Service) StopAndRemove() error {
 
83
        if !s.Installed() {
 
84
                return nil
 
85
        }
 
86
        if err := s.Stop(); err != nil {
 
87
                return err
 
88
        }
 
89
        return os.Remove(s.confPath())
 
90
}
 
91
 
80
92
// Remove deletes the service configuration from the init directory.
81
93
func (s *Service) Remove() error {
82
94
        if !s.Installed() {
83
95
                return nil
84
96
        }
85
 
        if err := s.Stop(); err != nil {
86
 
                return err
87
 
        }
88
97
        return os.Remove(s.confPath())
89
98
}
90
99
 
157
166
                return err
158
167
        }
159
168
        if c.Installed() {
160
 
                if err := c.Remove(); err != nil {
 
169
                if err := c.StopAndRemove(); err != nil {
161
170
                        return fmt.Errorf("upstart: could not remove installed service: %s", err)
162
171
                }
163
172
        }