Repository navigation
Automatic Updates
OWA downloads and installs its own releases: patch and minor releases by default, major releases too when Releases To Install says so. The scheduler's cron entry does the work, as the user it runs as; the web server never writes OWA's code. A release it does not install is announced in the bell, and you install it as on Updating.
The Updates screen (Settings → Server configuration → Updates) shows what automatic updates will do, and holds their settings. php cli.php cmd=core-update-status prints the same.
| A release package | OWA installed from owa_<version>_packaged.tar. An OWA directory inside a version control checkout (a .git, .svn, .hg or .bzr in it or any directory above it) is never updated automatically: update it with that. The bell still announces each release |
| The cron entry |
cli.php cmd=schedule-run every minute, as on [[Scheduled Jobs |
| The cron user can write OWA's code | [[Every file and every directory of it |
A full server |
Only a server whose [[role |
| The release's requirements | PHP, its extensions, the database server and the constants the release needs, as the CLI sees them |
| Room in PHP's temporary directory | For the release's tarball, and for the backup when a failed copy is put back: about twice a release's size. sys_temp_dir in the CLI's php.ini, else TMPDIR, else /tmp. cmd=core-install says when the CLI cannot write it at a new installation. Until it can, every core-update run fails, and System Health shows the failure |
| Room in the data directory | For the backup of every file the copy replaces or deletes, at most about a release's size |
cmd=core-update-status says which of these is missing. A release that cannot be installed here is also a notice in the bell, e-mailed to the admins, naming what to fix; it is judged again every hour.
Automatic Updates
| Setting | Constant | Default | Type | Scopes | Stored in | Description |
|---|---|---|---|---|---|---|
auto_update |
OWA_AUTO_UPDATE |
true |
boolean | install | database | Install Updates Automatically — Whether OWA downloads and installs its own releases, those Releases To Install names. Never on a version control checkout. |
auto_update_level |
OWA_AUTO_UPDATE_LEVEL |
minor |
select; one of minor (Patch and minor releases), major (Patch, minor and major releases) |
install | database | Releases To Install — Patch releases fix bugs and security problems; minor releases also add features; major releases can change what OWA needs and how it works. A release that does not install over the installed one is skipped for the highest that does, and installs on a later update. |
auto_update_days |
OWA_AUTO_UPDATE_DAYS |
(empty) | text; a list of days such as sat,sun: mon, tue, wed, thu, fri, sat or sun, separated by commas. | install | database | Update Days — The days an update may start on, such as sat,sun: within the Update Window on those days, or at any hour of them when there is no window. Empty: any day. |
auto_update_window |
OWA_AUTO_UPDATE_WINDOW |
02:00-06:00 |
text; two times, HH:MM-HH:MM, such as 02:00-06:00. | install | database | Update Window — The time an update may start in, such as 02:00-06:00, in this installation's timezone; patches wait for it too. Empty: any time, as soon as a release is downloaded. |
auto_update_email_success |
OWA_AUTO_UPDATE_EMAIL_SUCCESS |
true |
boolean | install | database | E-mail When An Update Installs — Whether the admins are e-mailed when an update installs. A failed update is always e-mailed. |
admin_notice_email |
OWA_ADMIN_NOTICE_EMAIL |
(empty) | text; an e-mail address, or several separated by commas. | install | database | Admin Notice E-mail Address — Where notices for OWA's administrators are e-mailed, such as an update that installed or failed. Separate several with commas. Empty sends them to every admin user's address. |
auto_update_releases_url (OWA_AUTO_UPDATE_RELEASES_URL) names the releases listing, in GitHub's format, and auto_update_download_url (OWA_AUTO_UPDATE_DOWNLOAD_URL) where every download comes from: <url><version>/<file>. Both default to OWA's update host, and can be set only in owa-config.php.
| The settings say | A release installs |
|---|---|
A window, such as 02:00-06:00
|
At the first release check inside it, on one of the Update Days, in the installation's timezone. A window that crosses midnight, such as 22:00-02:00, belongs to the day it starts on. Patch releases wait for it too |
| No window | At the release check that downloads it, on one of the Update Days, at any hour of it; with no days, on any day. A window not of the form HH:MM-HH:MM, as OWA_AUTO_UPDATE_WINDOW can be, is ignored the same way, and System Health and the Updates screen name it |
The release check runs once an hour. A window of an hour or more always contains one. The window bounds when an install may start.
A change takes effect at the next release check, within an hour, or at once with Check now.
The default listing is https://updates.openwebanalytics.com/releases, OWA's update host, which redirects to GitHub's releases API. The request adds from=<installed version>, and the host's access logs count installations and their versions from it. Nothing else about the installation is sent: no site URL, no installation id. The listing is requested four times a day, six hours apart, whether automatic updates are on or off. It also feeds the bell's release notifications. The tarball, its signature and SHA256SUMS are downloaded through the same host, from https://updates.openwebanalytics.com/download/<version>/, which redirects to the release's assets on GitHub. OWA requests nothing from GitHub's addresses directly. The notices and the bell link to a release's notes as https://updates.openwebanalytics.com/tag/<version>, which redirects to its page on GitHub.
Update Fetcher lists each request, its headers, and how to turn the requests off.
One job, core-update, does everything, every hour.
Four of the day's runs, six hours apart, read the releases listing. The hours, and a wait of up to a minute before each request, are fixed per installation. Each stores any new release in the bell, then chooses the release to update to: the highest version that is newer than the installed one, not a draft or pre-release, a step Releases To Install allows, and shipping owa_<version>_packaged.tar.
The bell gets the newest three releases at the first listing, then each release newer than the newest it holds; drafts are skipped. A release automatic updates will install is not announced: its OWA version is installed notice takes its place. Opening the bell does not contact the update host. A run by hand, php cli.php cmd=core-update, always reads the listing. Turning the core-update job off in owa-config.php stops the announcements and automatic updates:
define( 'OWA_SCHEDULED_JOBS', [
'core-update' => [ 'schedule' => 'off' ],
] );| Releases To Install | The release chosen |
|---|---|
Patch and minor releases (minor, the default) |
The highest newer release in the installed major version |
Patch, minor and major releases (major) |
The highest newer release of any major version |
Each release names the oldest release it installs over, upgrades_from in its release.php. A release whose upgrades_from is newer than the installed release is chosen all the same, and waits as a release with an unmet requirement does: no lower release installs in its place. A release with no upgrades_from installs over any release.
It downloads that tarball through the update host, checks it against the SHA-256 GitHub's listing gives for it and checks its signature. Every other tarball is deleted. A run that chooses nothing keeps a pending tarball newer than the installed release; with automatic updates off, every run deletes it.
Every run judges the newest downloaded release the settings allow, from its tarball on disk, with no download: its upgrades_from, the requirements, and what the copy needs (the table above). A release with an update that must be installed by hand never installs itself. Outside the update window it waits.
Inside the window, or with none, the run takes the install lock, copies the release's tarball into PHP's temporary directory and checks it against its signature again, and lists what the copy changes. It waits until the run's other jobs have finished, writes the install marker, owa-update.php, and then waits for every other cli.php run already going to end. Runs that start meanwhile stop at once. The web and tracking carry on. If the other runs have not ended after 5 minutes, it gives up, and the next release check tries again. Then it:
- Copies every file it will replace or delete into a backup directory,
owa-data/updates-<id>/backup-<id>/, and writes each file's path and SHA-256 in the install marker, with the paths of the files it will create. - Replaces each of the release's files that differs.
- In each directory the release ships, deletes the files it does not ship, and the directories that leaves empty.
The next run of cli.php, normally the scheduler's within a minute, starts the new release and finishes the install before whatever it was asked to do, in three steps: cmd=core-update-schema (its schema updates), cmd=publish-trackers, and a release check of its own as a test. A network failure does not fail that test. Once all three pass, the admins are told it installed, by e-mail too while E-mail When An Update Installs is on, and it deletes the marker, the backup and the release's tarball. A step that fails is a broken install.
The copy makes OWA's own directories match the release. In each top-level directory the release ships, such as Core/, modules/, public/ and vendor/, it deletes every file the release does not ship. A module directory in modules/ that the release does not ship is deleted too. It never deletes:
- files at the top of the OWA directory:
owa-config.php, and your own files, such as.htpasswdorrobots.txt..htaccessis replaced with the release's - a directory the release does not ship, such as
.well-known/ -
extensions/, where third-party modules go: the copy writes and deletes nothing there -
owa-data/, and the directoryOWA_DATA_DIRnames - the tracking bundles,
public/tracker/ortracker/underOWA_PUBLIC_PATH - the install marker and the install lock
A file you add inside one of OWA's own directories is deleted at the next install. Put a module of your own in extensions/<Name>/.
The updates directory, owa-data/updates-<id>/, holds one tarball at most, the pending one: the release chosen last, by a release check or by cmd=core-install --version, whether it is waiting or was refused. A release chosen after it replaces it. An install deletes it, and so does a release check with automatic updates off. An installation that is up to date holds none.
A replaced file keeps its mode; a new file takes the tarball's. OWA never changes the modes of your files. The cron user must be able to write every directory of OWA's code.
The database is not backed up. Back it up yourself, or with php cli.php cmd=backup.
Every release tarball is signed with an Ed25519 key, and the signature is published beside it as owa_<version>_packaged.tar.sig. A release that is not signed by one of the keys built into the installed release is never kept and never installs.
| What is signed | A statement naming the version, the tarball and its SHA-256. A signature is valid only for the release it names |
| The keys | Two are built into each release. A release that no longer lists a key retires it |
| Needs | PHP's sodium extension in the CLI. PHP bundles it |
| When | At the download, or when cmd=core-install --file reads a tarball, and again by the installer, on the copy it installs from. Putting a release back reads the backup, each file checked against the SHA-256 recorded in the install marker, owa-update.php, and no signature |
A tarball or a backed-up file in the data directory replaced by another account makes the install or the put-back fail. The cron user never writes through a link in the data directory.
The copy takes seconds; the new release starts at the next scheduler run, within a minute.
| Until the new release has started | Once it has started, while its schema updates run | |
|---|---|---|
| Admin and report screens | HTTP 503, "OWA is updating. This takes a minute or two.", with Retry-After: 60
|
The updater, as for any pending schema update |
install.php |
HTTP 503, as above | As at any other time |
| REST API | HTTP 503, error code busy
|
As for any pending schema update |
| Tracking |
log.php answers as usual and drops the beacon |
Beacons are queued, and ingested once the schema updates are applied |
cli.php cmd=schedule-run |
Does nothing while the installer waits for the other runs and during the copy, and exits 0; the next run starts the new release | Waits for the install lock |
Any other cli.php command |
While the installer waits and during the copy: "OWA is installing an update; try again in a minute.", exit code 75. After it, the command starts the new release first | The same |
While the installer waits for the other runs of cli.php to end, the admin screens, the REST API and tracking work as usual.
The install marker is owa-update.php in the OWA directory, beside owa-config.php. It is a PHP file that exits at once, followed by one line naming the two releases and how far the install has got. A request for it shows nothing. The install lock is owa-update-lock.php, beside the marker, held by the run that installs, finishes or puts a release back. It is also a PHP file that exits, followed by one line naming its holder.
php cli.php cmd=core-update-status shows the state at any time: what is downloaded, why it does or does not install, a failed install, and one under way. The Updates screen shows the same. Every notice below is also in the bell, and some are e-mailed. A notice gives paths relative to the OWA directory, and a data directory elsewhere as "the data directory"; cmd=core-update-status and the CLI give them in full.
A release whose install failed and was put back is tried again 6 hours later, 3 attempts in all. After the third failure, or at once for a release that did not start, it is skipped until a newer one is listed or you install it by hand. Nothing installs while the updates directory cannot be written.
A failed install shows at once on the Updates screen, in cmd=core-update-status and in System Health, red, whether it was reverted or is broken. It is a notice in the bell and an e-mail to the admins only when it needs you:
| The install | Notice | Severity |
|---|---|---|
| was reverted, and is tried again | none until the last attempt fails | |
| was reverted, and is not tried again | "Installing OWA x failed" | warning |
| is broken: a step after the new release started failed | "Installing OWA x failed", at once | critical |
Each says what failed and why, then either that the install was reverted, with whether it is tried again, or that it is broken and needs attention now, with what to do. The notice ends with a line for each check and step the install ran, from the release check to the one that failed. last-failure.json keeps those lines.
The checks change nothing in the OWA directory, and the release is not skipped. The check runs every hour (a listing or download only at the four daily listings), and the release installs once the cause is fixed. The problem shows at once on the Updates screen, in cmd=core-update-status (with what the check did) and in System Health, red, for as long as it lasts. Once it has lasted 12 hours (three listings six hours apart), a single notice and e-mail says what failed and why, that nothing was changed and the installed release runs as before, and what the check did.
| Case | What OWA does | What you do |
|---|---|---|
| GitHub cannot be reached, or rate-limits the request | Nothing new is downloaded. What was downloaded before still installs. The next listing tries again | Nothing, unless it lasts. php cli.php cmd=core-update shows the error |
| The download fails, or its SHA-256 does not match GitHub's | Nothing is kept. Tried again at each listing | Check the server can reach updates.openwebanalytics.com and GitHub over HTTPS, and that the data directory has room |
The release is not signed, or not by a key the installation trusts, or the CLI's PHP has no sodium extension |
Nothing is kept, as for a failed download, naming the reason | A release without a valid signature is not one to install. If it is OWA's, report it. For sodium, install or enable PHP's sodium extension for the CLI |
| A downloaded tarball no longer matches its signature | Deleted, and nothing installs; the next listing downloads it again | Find what else wrote the data directory |
| The release's asset was replaced on GitHub | Downloaded again | Nothing |
| A requirement is not met: PHP, an extension, the database server, a constant | Downloaded, and waits, naming each problem. Judged again every hour, and installed once they are fixed | Fix what it names |
| The CLI's PHP cannot write its temporary directory | Every core-update run fails, naming the directory; System Health shows the job as failed. Nothing is downloaded or installed |
Set sys_temp_dir in the CLI's php.ini to a directory the cron user can write, or free space there |
| The cron user cannot write a directory the release writes in, or the disk is short of room | The same, naming one directory or the disk | Fix the ownership or modes, or free space |
| The data directory's disk has no room for the backup | The same, naming the space needed | Free space there |
The release lacks a file the installer needs: updater.php, cli.php, owa_env.php, Core/Env.php or Tar.php
|
The same | Install it by hand, as on Updating. Releases before 2.0 have no updater.php
|
| An update in the release must be installed by hand | Downloaded, never installed automatically. A notice and an e-mail naming the update and the backup to take | Take the backup, then php cli.php cmd=core-install --version=<x.y.z>
|
More than one updates-* directory in the data directory |
Nothing is downloaded or installed | Delete all but one, or all of them: the next listing makes a new one |
owa-update-lock.php, an updates-* directory or its last-failure.json belongs to another user than the one the scheduler runs as, such as the web server's |
Nothing is downloaded or installed: core-update and core-install fail naming the file and both users, and System Health shows it red |
If no install is running, delete it |
| A major release, with Releases To Install at patch and minor releases | Announced in the bell only | Set Releases To Install to patch, minor and major releases, or install it by hand, as on Updating |
The release's upgrades_from is newer than the installed release |
It waits, judged again every hour, and says: "OWA <version> installs over <upgrades_from> or later; OWA <installed> is installed. Install <upgrades_from> first." | Install that release first, by hand: php cli.php cmd=core-install --version=<upgrades_from>
|
OWA_AUTO_UPDATE_LEVEL set to patch, or anything but minor or major
|
Every request is refused at boot, naming the constant | Set it to minor or major in owa-config.php
|
Until the new release has started, a failure puts the installed release back from the backup: every backed-up file is checked against the SHA-256 the install marker recorded before any is written, then each is written back, and the files the copy created are deleted. The release is tried again 6 hours later, 3 attempts in all, then skipped. A release that did not start is skipped at once.
| Case | What OWA does | What you do |
|---|---|---|
| A file cannot be written or deleted (a full disk, a file in the way) | Put back at once, by the same process, and tried again 6 hours later. A notice once the third attempt fails | Fix the cause the notice names. To install it now: php cli.php cmd=core-install --version=<x.y.z>
|
| The process is killed, or the server restarts | The marker says the copy was under way, with no installer holding the lock. The next cli.php run puts the installed release back, and the release is tried again 6 hours later |
Nothing |
| The new release does not start (a fatal error loading it) | The next two cli.php runs try to start it; the third puts the installed release back |
Report it. A later release with the fix installs as usual |
| A backed-up file is missing or changed | Nothing is written. The marker stays, last-failure.json lists the files, the site answers 503, and every cli.php run says what failed. OWA cannot start, and raises no notice |
As for a put-back that fails, below |
| Putting the installed release back fails | The marker stays. The site answers 503, and every cli.php run says what failed. OWA cannot start, and raises no notice |
Download the installed release, from https://updates.openwebanalytics.com/download/<installed>/owa_<installed>_packaged.tar, unpack it over the OWA directory as the cron user, then delete owa-update.php. Do not use the backup in owa-data/updates-*/: it may be what failed. Files the new release added stay until the next install |
From here nothing is undone. The schema updates may already have run, and the old release cannot read the new schema.
| Case | What OWA does | What you do |
|---|---|---|
| The process is killed during the schema updates | The next cli.php run takes the lock over and runs the rest |
Nothing |
| Finishing stops three times (a fatal error, memory) | A broken install: recorded with the step it was on, and the marker deleted. OWA runs as after a failed schema update | Fix the cause the notice names, then php cli.php cmd=core-update-schema
|
| A schema update fails | A broken install. The new release's files stay. Admin screens open the updater, beacons are queued, and no scheduled job runs but core-update. Reports wait |
Fix the cause the notice names, then run php cli.php cmd=core-update-schema. Once nothing is pending, it runs the rest of the finish (the tracking bundles, the release check) and completes the install, deleting the failure record and the replaced release's tarball. A newer release still installs |
| Republishing the tracking bundles fails | A broken install: OWA runs, with the bundles as they were | Fix the cause, then php cli.php cmd=core-update-schema, which finishes the install |
| The new release cannot run its own release check | A broken install. It may not install the release that fixes it | Install that release by hand once it is out |
In each case the run that was finishing exits 1, and no "installed" notice is raised.
| Case | What OWA does | What you do |
|---|---|---|
| The process holding the lock died | The next cli.php run takes the lock over. Where file locking (flock()) does not work, it waits until the lock file is 10 minutes old |
Nothing |
| The installer died waiting for the other runs | Nothing had changed: the next cli.php run deletes the marker |
Nothing |
Other runs of cli.php last more than 5 minutes |
Nothing is installed; the next release check tries again. A long command run by hand holds the install off until it ends. Where file locking does not work, the copy does not wait for them | Nothing |
| The update has not finished for over two hours | The 503 page and the REST error say it may be stuck |
php cli.php cmd=core-update-status says how far it got |
The install marker, owa-update.php, cannot be read |
The site answers 503, and every cli.php run exits 1 saying so |
If no install is running, delete owa-update.php
|
A release installed by hand while an older one waited for its window: nothing installs the older one, and its tarball is deleted once the install finishes.
Requires edit_settings. It shows the installed version, whether automatic updates are on and when they install, a downloaded release, and a failed install. Its buttons each queue a job that the scheduler runs within a minute; reload the page to see the result.
| Button | Runs | Does |
|---|---|---|
| Check now | cmd=core-update |
A release check now: it lists the releases, and installs if the window allows |
| Install now | cmd=core-install --version=<x.y.z> |
Fetches the downloaded release the screen names again by its version and installs it, whatever the update window says. Shown only when one is downloaded |
| Command | Does |
|---|---|
cmd=core-update-status |
What automatic updates will do |
cmd=core-update |
The automatic update now, as the scheduler runs it. --dry-run only says which release it would install |
cmd=core-install --version=<x.y.z> |
Fetches that release by its version through the update host and installs it now, whatever the settings say; the installed release again reinstalls it; an older one needs --force
|
cmd=core-install --file=<tarball> |
Installs the release in a tarball on this server, with no network request; --force as for --version
|
Each is on Command Line Interface.
This works whether automatic updates are on or off, as long as OWA was installed from a release package:
php cli.php cmd=core-install --version=2.0.3--version fetches the release's tarball and signature through the update host. It takes any release of any major version whose requirements the server meets and whose upgrades_from is the installed release or older, and checks its signature as for an automatic update. A tarball already in the updates directory is not downloaded again, and one that is refused stays there, so the same version tried again downloads nothing. Only one install runs at a time: one that starts while another holds the install lock stops before it downloads anything, with "Another install holds the install lock; try again in a minute." The files are copied when the command has finished, and it says so; the next cli.php run starts the new release and finishes the install. The installed release again is reinstalled, copying the files that differ. An older release needs --force, and never installs if it is older than the database schema: it prints the cmd=core-update-schema rollback= commands to run first instead. Installing a release this way clears any failed install of it, and automatic updates stop skipping it.
--file installs a release tarball already on the server. It needs no network access, for a server that cannot reach the update host:
php cli.php cmd=core-install --file=/tmp/owa_2.0.3_packaged.tar| The signature |
<tarball>.sig beside it, or --sig=<path>. Checked against the keys built into the installed release, as a download's is. A tarball with no signature, or one no built-in key made, is refused before anything changes |
| The version | Read from the tarball's release.php, else its Core/Env.php. The file name does not count |
| Then | As --version: the same checks, --force and schema rule. The tarball and its signature are copied into the updates directory |
--version and --file work only on an installed system. Run without either, cmd=core-install sets up a new installation or checks an installed one.
| Path | Mode | Holds |
|---|---|---|
owa-update.php, in the OWA directory |
0644 |
The install marker, while an install is under way |
owa-update-lock.php, in the OWA directory |
0644 |
The install lock, while it is held |
updates-<32 hex>/, in the data directory |
0755 |
Automatic updates' downloads |
updates-<32 hex>/owa_<version>_packaged.tar and .sig
|
0600 |
A release, checked, until it installs or another replaces it |
updates-<32 hex>/backup-<32 hex>/ |
0700 |
The files the copy replaced or deleted, from the copy until the new release has started and finished, or the files are put back |
updates-<32 hex>/last-failure.json |
0644 |
The release whose install failed, and why |
The web server user can list the directory and read the JSON file, for the Updates screen. It writes nothing there.
- Updating: updating by hand, and applying schema updates
- File System Permissions: who owns and writes OWA's files
- Notifications: the bell, and the notices automatic updates raise
-
Scheduled Jobs: the
core-updatejob
- Home
- Features
- New in 2.0
- Changes from 1.x
- Technical Requirements
- Installation
- Upgrading from 1.x
- Configuration
- Updating
- Automatic Updates
- Update Fetcher
- Troubleshooting
- Support
- Tracking Tag
- Javascript Tracker
- Sending Events
- Event Properties
- Custom Events
- Campaign Tracking
- Goals
- Ecommerce Tracking
- Currency Conversion
- Custom Dimensions
- Tracking Event Pipeline
- Integration Plugins
- Reports
- Realtime
- Custom Reports
- Heatmaps and Recordings
- Report Widgets
- Report Definitions
- Metrics and Dimensions
- Channels and Attribution
- REST API
- Reporting API
- Data Model
- Reporting Cubes
- Organizations, Properties and Profiles
- Settings
- User Accounts
- User Permissions
- Application Passwords
- Command Line Interface
- Scheduled Jobs
- Data Retention
- Partitioning
- Privacy
- Spam Detection
- Notifications
- Server Roles
- File System Permissions
- MaxMind GeoIP