Skip to content

fix: the Autostart switch now follows the crontab instead of a stale column - #68

Merged
FMSMITH91 merged 1 commit into
mainfrom
fix/autostart-follows-the-crontab
Aug 9, 2026
Merged

fix: the Autostart switch now follows the crontab instead of a stale column#68
FMSMITH91 merged 1 commit into
mainfrom
fix/autostart-follows-the-crontab

Conversation

@FMSMITH91

Copy link
Copy Markdown
Owner

Reported from the running panel: Scheduled Tasks shows

*/5 * * * *  /home/codserver/codserver monitor   [autostart]     OK · 2m ago

…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:

path gap
install_game_cron() schedules monitor at install, never recorded it
import adopts an existing setup, same gap
Scheduled Tasks deleting the line by hand — and the card's help text promises "deleting monitor turns Autostart off", which was simply untrue

Fix

The crontab is the source of truth. _sync_toggles_from_cron() uses the role that list_cron_jobs already 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 monitor is 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

…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>
@codacy-production

codacy-production Bot commented Aug 9, 2026

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Coverage 56.52% diff coverage · +0.33% coverage variation

Metric Results
Coverage variation +0.33% coverage variation (-1.00%)
Diff coverage 56.52% diff coverage

View coverage diff in Codacy

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.

@FMSMITH91
FMSMITH91 merged commit ee31427 into main Aug 9, 2026
19 checks passed
@FMSMITH91
FMSMITH91 deleted the fix/autostart-follows-the-crontab branch August 9, 2026 02:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant