Repository navigation
Conversation
Replace the system cron service with Supercronic, run as the linuxgsm user. - Scheduled jobs now get the container environment. Cron wiped it, so jobs ran without LGSM_* settings (e.g. backups used /app/serverfiles instead of /data/serverfiles, docker-gameserver#39). - No root service or setgid crontab binary is needed, so the container works with --security-opt no-new-privileges. - A crontab at /data/crontab (CRONTAB_FILE) is used instead of UPDATE_CHECK, survives restarts and image updates, and is reloaded on change. Invalid crontabs are logged and do not stop the container. - UPDATE_CHECK is converted to a valid schedule (1-59 minutes, or whole hours up to 24); other values fall back to 60 minutes with a warning instead of silently running hourly. - Supercronic is pinned and its SHA1 checksum verified at build time. - Scheduling starts after the server has started, so jobs cannot collide with the initial install or update. Based on ideas from #94 and #95. Co-authored-by: Agustín <17956512+snowyyd@users.noreply.github.com> Co-authored-by: WildPenguin <3398736+WildPenquin@users.noreply.github.com>
Supercronic now always runs on an internal crontab, and a 30 second loop refreshes it from /data/crontab, so creating, editing or deleting the file takes effect without restarting the container (deleting it switches back to UPDATE_CHECK). Polling also catches host-side edits on bind mounts where inotify events don't reach the container. Each change is validated first; an invalid file is logged and the previous schedule stays active. README: document the timezone, UPDATE_CHECK values, common task types, editing the file and scheduling from the host.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the system cron service with Supercronic, running as the
linuxgsmuser, and adds support for a persistent custom crontab.Builds on the ideas in #94 (@WildPenquin) and #95 (@snowyyd), who are credited as co-authors. Supersedes both; the 26.04, single-Dockerfile and Node.js parts of #95 already landed in #108.
Problems this fixes
LGSM_*settings. For example, backups used/app/serverfilesinstead of/data/serverfiles(question for linuxgsm/root user, and custom crontab docker-gameserver#39).--security-opt no-new-privileges,crontabcan't write the schedule, but the entrypoint still reported that update checks were scheduled (test T8 below).UPDATE_CHECKvalues over 59 silently ran hourly, e.g.*/90(cron's minute field stops at 59).Changes
cronpackage. Install Supercronic v0.2.49, pinned, with its published SHA1 checked at build time. AddENV CRONTAB_FILE=/data/crontab.cronservice./data/crontabexists it is used as-is (it lives on the data volume, so it survives restarts and image updates); otherwise one update job is generated fromUPDATE_CHECK./data/crontabtakes effect within 30 seconds, with no restart. Deleting it switches back toUPDATE_CHECK. Polling (rather than inotify on/data) also catches host-side edits on bind mounts where inotify events don't reach the container.UPDATE_CHECK:1-59minutes, or whole hours up to1440. Other values fall back to60with a warning;0disables.supercronic -testfirst. An invalid file is logged and the previous schedule stays active.docker logs(-passthrough-logs).supercronicis present and can parse a crontab.TZ),UPDATE_CHECKvalues, common task types (update, restart, backup, update-lgsm, mods/workshop updates, send, wipe), editing the file, and scheduling from the host.Testing
Built from this branch on a test server (Ubuntu 26.04 image) and tested with
jc2server:UPDATE_CHECK=600 */1 * * *;supercronicruns aslinuxgsm; no root cron serviceUPDATE_CHECK=1updateran; LinuxGSM loggedcore_exit.sh exiting with code: 0UPDATE_CHECK=90UPDATE_CHECK=0/data/crontablinuxgsmand sawLGSM_SERVERFILES=/data/serverfiles,LGSM_CONFIG,GAMESERVER,HOME=/data. Output appeared indocker logs. A line added while running took effect without a restart.--security-opt no-new-privilegeslinuxgsmno-new-privileges/var/spool/cron/: mkstemp: Permission denied, yet logs "update will check every 1 minutes"Live-reload tests (after the 30 second refresh loop was added), one container kept running throughout:
/data/crontab/data/crontabwhile runningdocker logsUPDATE_CHECKschedule; custom job stoppedUPDATE_CHECK=0, no fileno-new-privileges, file created while runninglinuxgsmAlso checked with shellcheck, hadolint (no new findings), actionlint and Prettier.
Notes
crontab -einside the container no longer works. It never persisted anyway, because the entrypoint overwrote the crontab. Use/data/crontabinstead.SUPERCRONIC_VERSIONandSUPERCRONIC_SHA1SUMtogether from the release notes.Closes #94
Closes #95