| 1 |
Get started |
| 2 |
----------- |
| 3 |
|
| 4 |
After installation, a mirrorbits systemd service is installed, however it's |
| 5 |
stopped and disabled, as there's no configuration for mirrorbits yet. |
| 6 |
|
| 7 |
Here's a very quick start: |
| 8 |
|
| 9 |
# Copy the sample config |
| 10 |
cp /usr/share/doc/mirrorbits/examples/mirrorbits.conf /etc/mirrorbits/ |
| 11 |
|
| 12 |
# Edit it |
| 13 |
$EDITOR /etc/mirrorbits/mirrorbits.conf |
| 14 |
|
| 15 |
# Start the service |
| 16 |
systemctl start mirrorbits.service |
| 17 |
|
| 18 |
# When all is good, don't forget to enable it |
| 19 |
systemctl enable mirrorbits.service |
| 20 |
|
| 21 |
|
| 22 |
HTML templates & third-party assets |
| 23 |
----------------------------------- |
| 24 |
|
| 25 |
Mirrorbits provides statistics if the query `?mirrorlist` or `?mirrorstats` is |
| 26 |
appended at the end of the URL requested. By default, it returns an HTML page |
| 27 |
that fetches assets (javascript and fonts) from third-parties. |
| 28 |
|
| 29 |
Mirrorbits allows the system administrator to change this behavior though, and |
| 30 |
serve local assets instead. Here's how to. |
| 31 |
|
| 32 |
First, let's run the helper script that downloads all the assets needed. We |
| 33 |
assume that we'll save those in `/srv/SITE/js`. |
| 34 |
|
| 35 |
mkdir /srv/SITE/js |
| 36 |
/usr/share/mirrorbits/contrib/localjs/fetchfiles.sh /srv/SITE/js |
| 37 |
|
| 38 |
Then configure Mirrorbits to use it. Edit the file `/etc/mirrorbits.conf` and |
| 39 |
set `LocalJSPath: /srv/SITE/js`. |
| 40 |
|
| 41 |
Finally you will need to configure your web server to make sure it can serve |
| 42 |
the files located in `/srv/SITE/js`. |
| 43 |
|
| 44 |
|
| 45 |
Debugging |
| 46 |
--------- |
| 47 |
|
| 48 |
To run mirrorbits in debug mode, you can create a drop-in file to set |
| 49 |
DAEMON_ARGS: |
| 50 |
|
| 51 |
cat << EOF > /etc/systemd/system/mirrorbits.service.d/debug.conf |
| 52 |
[Service] |
| 53 |
Environment=DAEMON_ARGS=-debug |
| 54 |
EOF |
| 55 |
|
| 56 |
|
| 57 |
Some notes regarding the systemd service |
| 58 |
---------------------------------------- |
| 59 |
|
| 60 |
`Requires=redis-server.service` is not a good idea. It means that if ever redis |
| 61 |
goes down, mirrorbits goes down as well. However mirrorbits is meant to keep |
| 62 |
operating even if the database is down, in that case it redirects requests to |
| 63 |
the fallback mirrors. |
| 64 |
|
| 65 |
`After=redis-server.service` is not set, meaning that on startup, mirrorbits |
| 66 |
doesn't wait for redis to be up, instead it stars asap and redirects requests |
| 67 |
to the fallback mirror until redis is up. If ever you don't like this |
| 68 |
behavior, you can create a systemd override file and set |
| 69 |
`After=redis-server.service`, or `After=redis-server@%i.service` for the |
| 70 |
parameterized service. Replace `redis` with `valkey` if you use valkey. |
| 71 |
|
| 72 |
By default mirrorbits writes its logs to stderr, so the most straightforward |
| 73 |
would be use systemd Standard{Output,Error}= directives and let systemd send |
| 74 |
the output to a log file. However there's a bit of a chicken-and-egg problem |
| 75 |
regarding the creation of the logs directory, as reported at |
| 76 |
https://github.com/systemd/systemd/issues/27591. So instead we use mirrorbits |
| 77 |
`-log` argument. |
| 78 |
|
| 79 |
`SystemCallFilter=~@resources` doesn't work, the program can't even start. |
| 80 |
This is due to Golang, since version 1.19 it calls setrlimit(2) at startup, cf. |
| 81 |
https://github.com/golang/go/commit/8427429c. |