State files
mirror.py separates read-only configuration from mutable runtime state. The
configuration file is never modified after mirror setup; all runtime state is
written to separate files under /var/lib/mirror/ and /var/www/mirror/.
Path layout
Path |
Purpose |
Writable by daemon? |
|---|---|---|
|
Main configuration |
No — read-only at runtime |
|
Persistent package state |
Yes (atomic rewrite on each status change) |
|
Unix sockets ( |
Yes |
|
Daemon logs; per-package logs under |
Yes |
|
Web-accessible status JSON for the mirror UI |
Yes |
Config invariant
/etc/mirror/config.json is read-only during daemon and worker runtime. Only
mirror setup ever writes it. Runtime state — sync status, error counts, log
paths, timestamps — lives exclusively in stat.json. There is intentionally no
Config.save() method; never write to config.json from the daemon.
stat.json — persistent package state
/var/lib/mirror/stat.json is rewritten atomically every time a package
changes status. Its default structure includes these fields (package configuration fields are
also retained):
{
"mirrorname": "<name>",
"packages": {
"<packageid>": {
"status": {
"status": "<STATUS>",
"statusinfo": { ... }
}
}
}
}
Per-package status object
Field |
Type |
Description |
|---|---|---|
|
string |
Current package status: |
statusinfo fields
These fields are defined in Package.StatusInfo in mirror/structure/__init__.py.
Field |
Type |
Description |
|---|---|---|
|
string or null |
Path of the most recent error log file. |
|
string or null |
Path of the most recent successful sync log file. |
|
string or null |
Path of the log file for the currently running sync. |
|
integer |
Number of consecutive errors since the last successful sync. Reset to 0 on |
|
float |
Unix timestamp (seconds) of the last successful sync completion. |
|
float |
Unix timestamp (seconds) of the last error. |
status.json — web status
/var/www/mirror/status.json is regenerated after each sync completes. It is
intended to be served by a web server so that users and monitoring tools can
inspect mirror freshness. Its shape is:
{
"lastupdate": <timestamp_ms>,
"mirrorname": "<name>",
"lists": ["<packageid>", ...],
"<packageid>": { ... },
...
}
Top-level fields
Field |
Type |
Description |
|---|---|---|
|
float |
Millisecond timestamp of when the status file was last written. |
|
string |
The |
|
array of strings |
Ordered list of package IDs included in this status file. |
Per-package entry fields
Each key in lists has a corresponding top-level entry with the following
fields:
Field |
Type |
Description |
|---|---|---|
|
string |
Human-readable package name. |
|
string |
Package identifier matching the key in |
|
string |
Current status: |
|
string or null |
Sync method in use (e.g. |
|
string |
Sync interval as an ISO 8601 duration or a special token ( |
|
string |
Upstream source URL. |
|
string |
Web-accessible path for this mirror on the local server. |
|
float |
Unix timestamp in seconds of the last completed sync. |
|
array of objects |
Related links, each with |
|
float |
Unix timestamps in seconds from |
|
string or null |
Log paths from |
|
integer |
Consecutive failures since the last success. |
Status plugins can add a plugins object to per-package entries or replace the
default payload through a transform hook.
Log file layout
Daemon logs are written under the path configured in settings.logfolder
(default /var/log/mirror/):
/var/log/mirror/
<year>/<month>/<date>.log # daemon log
packages/<year>/<month>/<day>/ # per-package sync logs
<HH>:<MM>:<SS>.<us>.<pkgid>.log
Log files are gzip-compressed on rotation when gzip: true is set in the
logger.fileformat and logger.packagefileformat config sections.