Ejemplo n.º 1
0
Archivo: task.go Proyecto: pulcy/j2
// unitNameExt returns the name of the systemd unit for this task.
func unitNameExt(t *jobs.Task, kind string, scalingGroup string) string {
	base := strings.Replace(t.FullName(), "/", "-", -1) + kind
	if t.GroupGlobal() && t.GroupCount() == 1 {
		return base
	}
	return fmt.Sprintf("%s@%v", base, scalingGroup)
}
Ejemplo n.º 2
0
Archivo: task.go Proyecto: pulcy/j2
// unitDescription creates the description of a unit
func unitDescription(t *jobs.Task, prefix string, scalingGroup uint) string {
	descriptionPostfix := fmt.Sprintf("[slice %d]", scalingGroup)
	if t.GroupGlobal() {
		descriptionPostfix = "[global]"
	}
	return fmt.Sprintf("%s unit for %s %s", prefix, t.FullName(), descriptionPostfix)
}
Ejemplo n.º 3
0
// createVolumeUnit
func createVolumeUnit(t *jobs.Task, vol jobs.Volume, volIndex int, engine engine.Engine, ctx generatorContext) (*sdunits.Unit, error) {
	namePostfix := createVolumeUnitNamePostfix(volIndex)
	volPrefix := path.Join(fmt.Sprintf("%s/%v", t.FullName(), ctx.ScalingGroup), vol.Path)
	volHostPath := fmt.Sprintf("/media/%s", volPrefix)

	unit, err := createDefaultUnit(t,
		unitName(t, namePostfix, ctx.ScalingGroup),
		unitDescription(t, fmt.Sprintf("Volume %d", volIndex), ctx.ScalingGroup),
		"service", namePostfix, ctx)
	if err != nil {
		return nil, maskAny(err)
	}
	cmds, err := engine.CreateVolumeCmds(t, vol, volIndex, volPrefix, volHostPath, unit.ExecOptions.Environment, ctx.ScalingGroup)
	if err != nil {
		return nil, maskAny(err)
	}
	setupUnitFromCmds(unit, cmds)

	return unit, nil
}