Skip to content

duty cycle #1

@jbrzusto

Description

@jbrzusto

Allow a service to be started and stopped with a given duty cycle during a shift.

Rationale

  • avoids having to code a version of duty cycle in each wrapped service
  • consolidates more of the "when am I running" concept and configuration into a single place
  • can permit sleeping the system more often

Details

  • Add new optional fields WorkFor and BreakFor to struct Shift. These are strings in the golang time.Duration format; they must either both be empty (which leads to the prior behaviour of running the service throughout the shift) or both be valid durations
  • if WorkFor and BreakFor are specified, then at the start of a shift, the service is run for a period of WorkFor duration and then stopped for a period of BreakFor duration, repeating until the end of the shift
  • two more new optional fields, StartWork and StartBreak, give shell commands to perform at the start of a work period and/or a break period, respectively. If given, these shell commands are executed synchronously before the associated systemd service (if any) is started or stopped
  • when overlapping shifts are merged, the WorkFor, BreakFor, StartWork, and StartBreak parameters from the shift with the most recent Start time are used.
  • by default, shiftwrap services are still considered to be running while taking a break during a shift, and this prevents shiftwrap from calling the idle handler. This behaviour can be changed by setting the global shiftwrap flag IdleDuringBreaks to true. In that case, break periods will be treated identically to periods outside of shifts when deciding whether to call the idle handler.
  • Setup and Takedown code are still only run at the start and end of a shift, not at transitions between work and break periods.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions