bundles/apt: introduce restart_triggers (restart services if another service has been upgraded)
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit
Some checks failed
bundlewrap/pipeline/head There was a failure building this commit
This commit is contained in:
parent
7ca24d27d3
commit
a24fb12c21
2 changed files with 16 additions and 0 deletions
|
@ -74,4 +74,19 @@ then
|
|||
date | mail -s "SYSREBOOTNOW ${node.name}" ${data['mail']}
|
||||
% endif
|
||||
systemctl reboot
|
||||
% if restart_triggers
|
||||
else
|
||||
% for affected, restarts in sorted(restart_triggers.items()):
|
||||
up_since=$(systemctl show "${affected}" | sed -n 's/^ActiveEnterTimestamp=//p' || echo 0)
|
||||
up_since_ts=$(date -d "$up_since" +%s || echo 0)
|
||||
now=$(date +%s)
|
||||
|
||||
if [ $((now - up_since_ts)) -lt 3600 ]
|
||||
then
|
||||
% for restart in sorted(restarts):
|
||||
systemctl restart "${restart}" || true
|
||||
% endfor
|
||||
fi
|
||||
% endfor
|
||||
% endif
|
||||
fi
|
||||
|
|
|
@ -33,6 +33,7 @@ files = {
|
|||
'context': {
|
||||
'clean_old_kernels': node.metadata.get('apt/clean_old_kernels', True),
|
||||
'data': node.metadata.get('apt/unattended-upgrades', {}),
|
||||
'restart_triggers': node.metadata.get('apt/restart_triggers', {}),
|
||||
}
|
||||
},
|
||||
'/etc/cloud': {
|
||||
|
|
Loading…
Reference in a new issue