Example #1
0
func (hl *Launchable) stop(serviceBuilder *runit.ServiceBuilder, sv runit.SV) error {
	executables, err := hl.Executables(serviceBuilder)
	if err != nil {
		return err
	}

	for _, executable := range executables {
		_, err := sv.Stop(&executable.Service, hl.RestartTimeout)
		if err != nil && err != runit.Killed {
			// TODO: FAILURE SCENARIO (what should we do here?)
			// 1) does `sv stop` ever exit nonzero?
			// 2) should we keep stopping them all anyway?
			return err
		}
	}
	return nil
}
Example #2
0
func (hl *Launchable) stop(serviceBuilder *runit.ServiceBuilder, sv *runit.SV) error {
	executables, err := hl.Executables(serviceBuilder)
	if err != nil {
		return err
	}

	for _, executable := range executables {
		// if we use sv -w to wait for the service to stop and then SIGKILL, we
		// will also kill the preparer itself before it can restart. do not use
		// sv -w yet.
		_, err := sv.Stop(&executable.Service)
		if err != nil {
			// TODO: FAILURE SCENARIO (what should we do here?)
			// 1) does `sv stop` ever exit nonzero?
			// 2) should we keep stopping them all anyway?
			return err
		}
	}
	return nil
}
Example #3
0
func (l *Launchable) stop(serviceBuilder *runit.ServiceBuilder, sv runit.SV) error {
	executables, err := l.Executables(serviceBuilder)
	if err != nil {
		return err
	}

	for _, executable := range executables {
		_, err := sv.Stop(&executable.Service, l.RestartTimeout)
		if err != nil {
			cmd := exec.Command(
				l.P2Exec,
				p2exec.P2ExecArgs{
					WorkDir: l.InstallDir(),
					Command: []string{*RuncPath, "kill", "SIGKILL"},
				}.CommandLine()...,
			)
			err = cmd.Run()
			if err != nil {
				return util.Errorf("%s: error stopping container: %s", l.ServiceID_, err)
			}
		}
	}
	return nil
}