emustation: speed up "Restart EmulationStation"

Reported as working but very slow (long black screen). Two OS-side
contributors cut, the rest (ES gamelist re-scan) is inherent:

- es_settings (ExecStartPre, runs on every ES start) unconditionally ran
  `systemctl restart tz-data.service` synchronously, blocking the relaunch.
  Only restart it when the timezone actually changed.
- emustation.service RestartSec was 2s of dead time before the relaunch.
  Drop to 1s; StartLimitIntervalSec/StartLimitBurst already guard crash-loops.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Douglas Teles
2026-06-25 23:06:48 -03:00
parent 4c0e295db2
commit d65cb345bf
2 changed files with 13 additions and 2 deletions
@@ -10,8 +10,15 @@ export SDL_AUDIODRIVER=pulseaudio
TZ=$(get_setting system.timezone)
echo -n "TIMEZONE=${TZ}" > /storage/.cache/timezone
# es_settings is ExecStartPre for emustation.service, so it runs on every ES
# (re)start. Restarting tz-data is synchronous and blocks the ES relaunch
# (a visible chunk of the "Restart EmulationStation" black screen), yet it
# only matters when the timezone changed. Skip it otherwise.
PREV_TZ="$(cat /storage/.cache/system_timezone 2>/dev/null)"
echo -n "${TZ}" >/storage/.cache/system_timezone
systemctl restart tz-data.service
if [ "${TZ}" != "${PREV_TZ}" ]; then
systemctl restart tz-data.service
fi
MYLOCALE=$(get_setting system.language)
if [[ -n "${MYLOCALE}" ]]
@@ -19,8 +19,12 @@ ExecStartPre=/usr/bin/es_settings
ExecStart=/usr/bin/emulationstation --log-path /var/log --no-splash
KillMode=process
TimeoutStopSec=3
# RestartSec is pure dead time on a user-initiated "Restart EmulationStation"
# (and after a crash). StartLimitIntervalSec/StartLimitBurst above already
# stop a crash-loop from flooding, so keep just enough debounce to avoid a
# tight loop.
Restart=always
RestartSec=2
RestartSec=1
[Install]
WantedBy=archr.target