logoalt Hacker News

westurnertoday at 4:03 AM0 repliesview on HN

A systemd unit file with RestartMaxDelaySec= for exponential back off:

  [Unit]
  Description="test exponential retry"
  
  [Service]
  ExecStart=-/bin/sh -c "date -Is"
  Type=simple
  Restart=on-failure
  RestartSec=60ms
  RestartMaxDelaySec=¶
  RestartSteps=
  
  # StartLimitBurst=2
  # StartLimitIntervalSec=30
  
  # OnFailure=
   
  # TimeoutStartSec=
  # TimeoutStartFailureMode=
   
  # WatchdogSec=
   
  # RestartPreventExitStatus=
  # RestartForceExitStatus=
  
  # OOMPolicy=
   
  [Install]
  WantedBy=default.target
  
man systemd.service https://www.freedesktop.org/software/systemd/man/latest/syst...

man systemd.unit https://www.freedesktop.org/software/systemd/man/latest/syst...

man systemd.resource-control https://www.freedesktop.org/software/systemd/man/latest/syst...

man systemd.service > "Table 1. Exit causes and the effect of the Restart= settings" https://www.freedesktop.org/software/systemd/man/latest/syst...

"RFE: Exponentially increasing RestartSec=" https://github.com/systemd/systemd/issues/6129#issuecomment-...

"core: add RestartSteps= and RestartSecMax= to dynamically increase interval between auto restarts" https://github.com/systemd/systemd/pull/26902

> RestartSteps= accepts a positive integer as the number of steps to take to increase the interval between auto-restarts from RestartSec= to RestartMaxDelaySec=

/? RestartMaxDelaySec https://www.google.com/search?q=RestartMaxDelaySec

Is this where to add jitter?

"core/service: make restart delay increase more smoothly" https://github.com/systemd/systemd/pull/28266/files