Update Mechanism in XC_VM¶
The XC_VM update system is implemented as a multi-layered process, from the web interface to system-level scripts. This approach ensures reliability, automation, and data integrity during panel updates.
📋 For a step-by-step guide with screenshots, see Updating a Server.
1. Update Initiation¶
The process begins when the administrator clicks the "Update" button in the web interface.
- A signal named
updateis inserted into thesignalstable in the database. - This signal acts as a trigger for the entire update procedure.
2. CRON Trigger¶
Every minute, the following CRON job runs:
The root_signals cron job checks for new signals.
When it detects an update signal, it launches:
3. Update Management (PHP Layer)¶
Core logic resides in the UpdateCommand class:
At this stage the following actions are performed:
- Detect the current panel type (
MAINorLB). - Fetch update metadata from GitHub:
- Direct link to the update archive.
- SHA checksum for integrity verification.
- Download the archive to a temporary directory.
- Verify the downloaded file matches the expected hash.
- On MAIN only: dump the database to
backups/pre_update_<from>_to_<to>_<timestamp>.sql, the copy of the data from before the migrations. It is best effort: when the disk has no room for it (twice the size of the dumped tables, plus 512 MiB) or the dump fails, the update goes on without one andupdate.logsays so. One such file is kept, the newest; it counts toward Local Backups to Keep. - Hand over control to the system-level updater (Python):
💡 After the Python updater finishes, it calls
console.php update post-updatewhich triggers database migrations and post-update cleanup.
4. System-Level Update (Python Layer)¶
Control is transferred to the Python script:
It performs privileged system operations:
- Re-verify the archive checksum.
- Stop the panel to prevent conflicts during update.
- Extract the archive into a temporary directory:
- Remove excluded directories from the temp copy — binaries, configs, and user data that must not be overwritten:
bin/ffmpeg_bin, bin/nginx, bin/nginx_rtmp, bin/php, bin/redis, bin/install, bin/maxmind, bin/certbot, content, backups, tmp, config, signals
- Copy remaining files over the live installation:
- Fix ownership:
- Run post-update tasks:
- Restart the panel in normal operating mode.
- Cleanup the temporary directory and delete the archive.
ℹ️ The same archive is used for both installation and update. Filtering happens on the server at update time — the exclude list is defined directly in
src/update.
5. Update Completion¶
Final steps are executed in the post-update phase of UpdateCommand:
- If LB auto-update is enabled and the main node (
MAIN) was updated → createupdatesignals for all Load Balancers. A Load Balancer that is offline at that moment is told as soon as it is back online. A Load Balancer always installs MAIN's release, never a newer one. - Update the panel version in the database.
- Remove obsolete files.
- Re-apply correct permissions:
- Reload systemd daemons:
- Verify panel status:
- Mark the update process as complete.
A database migration that fails is not recorded and runs again at every console.php status and every boot. It shows in four places:
- the update's output and
sudo /home/xc_vm/console.php statusprint[FAIL] <file>with the database's message on the[ERR]line before it; update.loghas anERRORline per failed file, and its last line says whether the run ofstatusat the end of the update applied it;- Panel Logs gets a
migrationrow naming the file at each failed attempt; - the dashboard's Database schema row shows a warning until a run applies every migration.
console.php db:migrate exits with status 1 when a migration failed.
6. Full Workflow Diagram¶
[ Web Interface ]
│
▼
[ DB: "update" signal ]
│
▼
[ CRON → console.php cron:root_signals ]
│
▼
[ UpdateCommand (PHP): download + verify hash ]
│
▼
[ update (Python): extract to /tmp → remove excluded → copy over ]
│
▼
[ post-update → UpdateCommand ]
│
▼
[ Finalize, restart daemons, update version in DB ]
Rollback (Downgrade)¶
A server can also be rolled back to an earlier release. This mirrors the update flow above but targets a chosen version instead of the latest — the same signal → CRON → PHP → Python pipeline and the same src/update applier are reused. Rollback is per-server, so MAIN and each LB can be downgraded independently.
-
Initiation. In Servers → Manage Servers, the per-server actions menu has a Rollback Version item. It opens a dialog listing earlier releases (pre-releases tagged
(beta)), fetched via therollback_versionsAPI action (GitHubReleases::getPreviousVersions()). Choosing a version inserts a signal —{"action":"rollback","version":"X.Y.Z"}— for that server. -
CRON trigger.
cron:root_signalshandles therollbacksignal by launching:
- PHP layer (
UpdateCommand,rollbackcase). - Validate the target (
X.Y.Z, strictly older than the current version). - On MAIN only: take an automatic database backup to
backups/pre_rollback_<from>_to_<to>_<timestamp>.sql, aborting if it fails. LB nodes have no database and skip this. - Resolve the exact version's archive via
GitHubReleases::getVersionFile()(MAIN →xc_vm.tar.gz, LB →loadbalancer.tar.gz), download it, and verify the MD5. - On MAIN, for a target up to 2.5.3 only: run the
migrations/database/down/file of every applied migration the target does not carry. A target from 2.6.0 on runsmigrations/database/up/, which the applier leaves in place, and would apply those files again; its schema is left as it is. -
Hand over to the same Python updater (
src/update). -
System + completion. Identical to an update: the Python script stops the panel, replaces the tree (preserving binaries/config/data), and
post-updatesets the version in the database to the rolled-back release and restarts the panel.
The version list is channel-aware: the stable channel offers only stable releases, beta and dev also offer (beta) pre-releases. Nightly builds (X.Y.Z-dev.N) are never listed: the rollback flow accepts X.Y.Z tags only.
⚠️ A downgrade to 2.6.0 or later does not undo database migrations. The schema is kept backward-compatible, and the automatic MAIN backup is the recovery path. The Python applier copies over the tree (
cp -a) without deleting files, so files added by a newer release remain until a subsequent update.
Key Features¶
- Double integrity check (both PHP and Python layers verify the hash).
- Automatic propagation of updates from MAIN to all Load Balancers.
- Cleanup of deprecated files and permission normalization.
- Safe panel restart after installation.
- Flexibility & autonomy thanks to CRON + signal-based triggering.