fix: the Autostart switch now follows the crontab instead of a stale column - #68
Merged
Merged
Conversation
…column
Reported from the panel: Scheduled Tasks shows
`*/5 * * * * /home/codserver/codserver monitor [autostart]`, last run OK 2m
ago — while the Details page shows Auto-start OFF. Both are reading the same
concept; only one of them is right.
What "Autostart" MEANS is "is that monitor line scheduled". It was stored as
a column, and three paths changed the line without touching the column:
install_game_cron() schedules monitor at install and never recorded it
import adopts an existing setup, same gap
Scheduled Tasks deleting the line by hand — and the card's own help
text promises "deleting monitor turns Autostart off",
which was simply not true
So the crontab is the source of truth now. _sync_toggles_from_cron() reads the
`role` that list_cron_jobs already returns for each line and reconciles both
switches — Autostart and Daily restart, which had the identical problem — on
every read, add and delete of the cron list. Install records the autostart it
just scheduled, fixing the root cause for new servers.
An existing server heals the next time its Files & Config page loads, since
that page lists the cron.
Three checks drive the real endpoint with a stubbed crontab: Off + monitor
present corrects to On, the line disappearing turns it Off, and deleting it
turns the switch off the way the card says it will. Mutation-verified.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Coverage variation | ✅ +0.33% coverage variation (-1.00%) |
| Diff coverage | ✅ 56.52% diff coverage |
Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (3d19173) 11936 5750 48.17% Head commit (d5a9581) 11957 (+21) 5800 (+50) 48.51% (+0.33%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>
Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#68) 23 13 56.52% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
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.
Reported from the running panel: Scheduled Tasks shows
…while the Details page shows Auto-start: Off. Same concept, two answers, and the switch was the wrong one.
Why
What "Autostart" means is "is that monitor line scheduled". It was stored as a database column, and three paths changed the line without touching the column:
install_game_cron()monitorat install, never recorded itmonitorturns Autostart off", which was simply untrueFix
The crontab is the source of truth.
_sync_toggles_from_cron()uses therolethatlist_cron_jobsalready returns for every line (autostart/daily-restart) and reconciles on every read, add and delete of the cron list. Daily restart had the identical problem and is fixed with it. Install now records the autostart it just scheduled, which closes the root cause for new servers.Your existing server heals the next time its Files & Config page loads, since that page lists the cron.
Tests
Three checks drive the real endpoint with a stubbed crontab — Off while
monitoris present corrects to On, the line disappearing turns it Off, and deleting it turns the switch off the way the card says. Mutation-verified by removing the reconcile.unit 839 · smoke 297 → 300 · rbac 65 · manage 21 · template_actions 7 · lint clean.
🤖 Generated with Claude Code