Skip to content

Commit

Permalink
Merge pull request #128 from flyingcircusio/timer-user-config
Browse files Browse the repository at this point in the history
make the user configurable a systemd timer runs as
  • Loading branch information
frlan authored Aug 17, 2023
2 parents d7a5d36 + 0f5ebfa commit c07bcd5
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/batou_ext/cron.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,19 @@ class SystemdTimer(batou.component.Component):
"""

_required_params_ = {"command": "/bin/true", "onCalendar": "*/4 * * * * "}
_required_params_ = {"command": "/bin/true", "onCalendar": "02:00:00"}

namevar = "tag"
command = batou.component.Attribute(str)
onCalendar = batou.component.Attribute(str)
timeout = "1h"
description = None
run_as = batou.component.Attribute(
str,
default=batou.component.ConfigString(
"{{component.environment.service_user}}"
),
)

def configure(self):
if self.description is None:
Expand Down Expand Up @@ -177,7 +183,7 @@ def configure(self):
description = "{{component.description}}";
serviceConfig = {
Type = "oneshot";
User = "{{component.environment.service_user}}";
User = "{{component.run_as}}";
ExecStart = "{{component.wrapped_command}}";
TimeoutStartSec = "{{component.timeout}}";
};
Expand Down

0 comments on commit c07bcd5

Please sign in to comment.