Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Format infra Markdown

Manav Rathiff45b0c4708f
diff --git a/infra/README.md b/infra/README.md
index e1ad6de6e4..87934d2a4a 100644
--- a/infra/README.md
+++ b/infra/README.md
@@ -2,7 +2,4 @@
Various knick-knacks that we use when hosting our servers.
-These are not needed for running Ente's server or for self-hosting, these are
-just additional services we run to make our infrastructure more robust. As such,
-it's unlikely that you'll find the pieces here directly useful for your needs,
-but feel free to have a look around if you're curious!
+These are not needed for running Ente's server or for self-hosting, these are just additional services we run to make our infrastructure more robust. As such, it's unlikely that you'll find the pieces here directly useful for your needs, but feel free to have a look around if you're curious!
diff --git a/infra/copycat-db/README.md b/infra/copycat-db/README.md
index f12612b838..f5f8e3d687 100644
--- a/infra/copycat-db/README.md
+++ b/infra/copycat-db/README.md
@@ -83,9 +83,9 @@ Location of the config file, that contains the destination bucket where you want
Specifically, the config file contains two remotes:
-- The bucket itself, where data will be stored.
+- The bucket itself, where data will be stored.
-- A "crypt" remote that wraps the bucket by applying client side encryption.
+- A "crypt" remote that wraps the bucket by applying client side encryption.
The configuration file will contain (lightly) obfuscated versions of the password, and as long as we have the configuration file we can continue using rclone to download and decrypt the plaintext. Still, it is helpful to retain the original password too separately so that the file can be recreated if needed.
@@ -112,7 +112,9 @@ The service logs to its standard out/error. The systemd unit is configured to ro
The provided `test.sh` script can be used to do a smoke test for building and running the image. For example,
- ./test.sh bin/bash
+```sh
+./test.sh bin/bash
+```
gives us a shell prompt inside the built and running container.
@@ -134,33 +136,45 @@ Ensure that promtail is running, and is configured to scrape `/root/var/logs/cop
Create that the config and log destination directories
- sudo mkdir -p /root/var/config/scw
- sudo mkdir -p /root/var/config/rclone
- sudo mkdir -p /root/var/logs
+```sh
+sudo mkdir -p /root/var/config/scw
+sudo mkdir -p /root/var/config/rclone
+sudo mkdir -p /root/var/logs
+```
Create the env, scw and rclone configuration files
- sudo tee /root/copycat-db.env
- sudo tee /root/var/config/scw/copycat-db-config.yaml
- sudo tee /root/var/config/rclone/copycat-db-rclone.conf
+```sh
+sudo tee /root/copycat-db.env
+sudo tee /root/var/config/scw/copycat-db-config.yaml
+sudo tee /root/var/config/rclone/copycat-db-rclone.conf
+```
Add the service definition, and start the service
- scp copycat-db.{service,timer} instance:
+```sh
+scp copycat-db.{service,timer} instance:
- sudo mv copycat-db.{service,timer} /etc/systemd/system
- sudo systemctl daemon-reload
+sudo mv copycat-db.{service,timer} /etc/systemd/system
+sudo systemctl daemon-reload
+```
To start the cron job
- sudo systemctl start copycat-db.timer
+```sh
+sudo systemctl start copycat-db.timer
+```
The timer will trigger the service on the specified schedule. In addition, if you wish to force the job to service immediately
- sudo systemctl start copycat-db.service
+```sh
+sudo systemctl start copycat-db.service
+```
## Updating
To update, run the [GitHub workflow](../../.github/workflows/copycat-db-release.yaml) to build and push the latest image to our Docker Registry, then restart the systemd service on the instance
- sudo systemctl restart copycat-db
+```sh
+sudo systemctl restart copycat-db
+```
diff --git a/infra/experiments/logs-viewer/README.md b/infra/experiments/logs-viewer/README.md
index 72692ad769..61b6d16768 100644
--- a/infra/experiments/logs-viewer/README.md
+++ b/infra/experiments/logs-viewer/README.md
@@ -5,11 +5,13 @@ A web-based log viewer for analyzing Ente application logs. This tool provides s
## Features
### πŸ“ File Upload
+
- Drag and drop ZIP files containing log files
- Automatic extraction and parsing of log files
- Support for daily log files format (YYYY-M-D.log)
### πŸ” Search and Filtering
+
- **Text Search**: Search through log messages, logger names, and error content
- **Logger Filtering**: Use `logger:ServiceName` syntax to filter by specific loggers
- **Wildcard Support**: Use `logger:Auth*` to match all loggers starting with "Auth"
@@ -18,11 +20,13 @@ A web-based log viewer for analyzing Ente application logs. This tool provides s
- **Timeline Filtering**: Filter by date/time ranges
### πŸ“Š Analytics
+
- Logger statistics showing most active components
- Log level distribution charts
- Click-to-filter from analytics charts
### 🎨 UI Features
+
- **Color-coded log levels**: Red for SEVERE, orange for WARNING, etc.
- **Process indicators**: Visual distinction between foreground and background processes
- **Active filter chips**: Visual indication of applied filters with easy removal
@@ -31,6 +35,7 @@ A web-based log viewer for analyzing Ente application logs. This tool provides s
- **Responsive design**: Works on desktop and mobile devices
### πŸ“€ Export
+
- Export filtered logs as text files
- Copy individual log entries to clipboard
- Maintain original formatting and error details
@@ -40,10 +45,12 @@ A web-based log viewer for analyzing Ente application logs. This tool provides s
### Starting the Application
1. **Local Development**:
+
```sh
cd infra/experiments/logs-viewer
python3 -m http.server 8080
```
+
Open http://localhost:8080 in your browser
2. **Upload Log Files**:
@@ -59,10 +66,12 @@ The viewer understands the Ente log format as generated by `super_logging.dart`:
```
**Examples**:
+
- `[bg] [SyncService] [INFO] [2025-08-24 01:36:03.677678] Syncing started`
- `[CollectionsService] [WARNING] [2025-08-24 01:36:04.123456] Connection failed`
**Multi-line Error Support**:
+
- Automatically parses `β€·` error detail lines
- Extracts stack traces and error IDs
- Handles inline error messages and exceptions
@@ -84,6 +93,7 @@ The viewer understands the Ente log format as generated by `super_logging.dart`:
## Technical Details
### Supported Log Levels
+
- **SHOUT**: Purple - Highest priority
- **SEVERE**: Red - Errors and exceptions
- **WARNING**: Orange - Warning conditions
@@ -92,11 +102,13 @@ The viewer understands the Ente log format as generated by `super_logging.dart`:
- **FINE/FINER/FINEST**: Gray - Debug messages
### Process Types
+
- **Foreground**: Main app processes
- **Background (bg)**: Background tasks
- **Firebase Background (fbg)**: Firebase-related background processes
### Performance
+
- Lazy loading: Only renders visible log entries
- Efficient filtering: Client-side filtering with optimized algorithms
- Memory management: Handles large log files (tested with 100k+ entries)
@@ -108,6 +120,7 @@ For testing, you can use any ZIP file containing `.log` files from Ente mobile a
## Development
### File Structure
+
```
logs-viewer/
β”œβ”€β”€ index.html # Main HTML structure
@@ -118,12 +131,14 @@ logs-viewer/
```
### Key JavaScript Classes
+
- `LogViewer`: Main application class
- Log parsing logic in `parseLogFile()` and `parseLogLine()`
- Filter management in `applyCurrentFilter()`
- UI rendering in `renderLogs()` and `createLogEntryHTML()`
### Adding Features
+
1. **New Filter Types**: Extend `currentFilter` object and `matchesFilter()` method
2. **New Log Formats**: Update parsing patterns in `parseLogLine()`
3. **UI Components**: Add HTML elements and CSS classes, wire up in `initializeEventListeners()`
@@ -153,6 +168,7 @@ logs-viewer/
- Search is case-insensitive for message content
### Browser Compatibility
+
- **Recommended**: Chrome 80+, Firefox 75+, Safari 13+
- **Required**: ES6 support, Fetch API, File API
- **Dependencies**: JSZip library for ZIP file handling
@@ -164,4 +180,4 @@ logs-viewer/
- Log correlation and grouping
- Performance metrics dashboard
- Dark theme support
-- Export to JSON/CSV formats
\ No newline at end of file
+- Export to JSON/CSV formats
diff --git a/infra/ml/test/README.md b/infra/ml/test/README.md
index 94798c93c8..62e4bfef44 100644
--- a/infra/ml/test/README.md
+++ b/infra/ml/test/README.md
@@ -72,8 +72,7 @@ Useful optional filters:
## Ground-Truth Decode Visualizer
-Render the exact Python ground-truth decode output (including EXIF orientation handling)
-for every manifest fixture, then review the generated gallery.
+Render the exact Python ground-truth decode output (including EXIF orientation handling) for every manifest fixture, then review the generated gallery.
```sh
uv run --project infra/ml --no-sync --with pillow-heif \
@@ -83,8 +82,7 @@ uv run --project infra/ml --no-sync --with pillow-heif \
--open
```
-This script calls `ground_truth._runtime.decode_image_rgb` directly, so it tracks
-decode/orientation behavior changes in the Python reference pipeline.
+This script calls `ground_truth._runtime.decode_image_rgb` directly, so it tracks decode/orientation behavior changes in the Python reference pipeline.
Outputs:
diff --git a/infra/ml/test/ground_truth/README.md b/infra/ml/test/ground_truth/README.md
index 19e859a547..d3a8c86f26 100644
--- a/infra/ml/test/ground_truth/README.md
+++ b/infra/ml/test/ground_truth/README.md
@@ -4,20 +4,16 @@ This directory stores the Python ground-truth assets for the ML indexing parity
- `manifest.json`: corpus definition and per-item metadata.
- `schema.py`: strict shared result schema used by all runners.
-- `clip.py`, `face_detection.py`, `face_alignment.py`, `face_embedding.py`, `pipeline.py`:
- ONNX-backed Python reference pipeline that mirrors the mobile `analyzeImageStatic`
- flow using Pillow + OpenCV + ONNX Runtime.
+- `clip.py`, `face_detection.py`, `face_alignment.py`, `face_embedding.py`, `pipeline.py`: ONNX-backed Python reference pipeline that mirrors the mobile `analyzeImageStatic` flow using Pillow + OpenCV + ONNX Runtime.
-Runtime outputs (`goldens/*.json`, `goldens/results.json`, and
-`infra/ml/test/out/parity/**`) are generated on demand and are gitignored.
+Runtime outputs (`goldens/*.json`, `goldens/results.json`, and `infra/ml/test/out/parity/**`) are generated on demand and are gitignored.
## Dataset Source
The default corpus is sourced from:
- `https://github.com/laurenspriem/test-fixtures/tree/ml_more_test_data/ml/indexing/v1`
-- Canonical fixture metadata:
- `https://raw.githubusercontent.com/laurenspriem/test-fixtures/ml_more_test_data/ml/indexing/v1/manifest.json`
+- Canonical fixture metadata: `https://raw.githubusercontent.com/laurenspriem/test-fixtures/ml_more_test_data/ml/indexing/v1/manifest.json`
`manifest.json` in this directory uses:
@@ -27,21 +23,15 @@ The default corpus is sourced from:
## ONNX Models
-`generate_goldens.py` downloads and caches the mobile indexing ONNX models under
-`infra/ml/test/.cache/onnx_models/`:
+`generate_goldens.py` downloads and caches the mobile indexing ONNX models under `infra/ml/test/.cache/onnx_models/`:
- `mobileclip_s2_image.onnx`
- `yolov5s_face_640_640_dynamic.onnx`
- `mobilefacenet_opset15.onnx`
-HEIC/HEIF decoding requires the `pillow-heif` plugin (declared in
-`infra/ml/pyproject.toml`).
+HEIC/HEIF decoding requires the `pillow-heif` plugin (declared in `infra/ml/pyproject.toml`).
-If Pillow decode fails, Python ground truth now fails by default instead of
-silently falling back to OpenCV decode (to avoid EXIF-orientation drift in
-parity outputs). Set `ML_PARITY_ALLOW_OPENCV_DECODE_FALLBACK=1` only for
-debugging; this emits explicit warnings and should not be used for trusted
-parity runs.
+If Pillow decode fails, Python ground truth now fails by default instead of silently falling back to OpenCV decode (to avoid EXIF-orientation drift in parity outputs). Set `ML_PARITY_ALLOW_OPENCV_DECODE_FALLBACK=1` only for debugging; this emits explicit warnings and should not be used for trusted parity runs.
## Generate Goldens
@@ -51,9 +41,7 @@ uv run --project infra/ml --no-sync --with pillow-heif python infra/ml/test/tool
--output-dir infra/ml/test/out/parity/python
```
-`generate_goldens.py` expects fixture files to already be present locally.
-`run_ml_parity_tests.sh` is responsible for clearing `infra/ml/test/test_data/ml-indexing/v1`,
-downloading fixtures, and then calling the generator.
+`generate_goldens.py` expects fixture files to already be present locally. `run_ml_parity_tests.sh` is responsible for clearing `infra/ml/test/test_data/ml-indexing/v1`, downloading fixtures, and then calling the generator.
## Compare Against Platforms
diff --git a/infra/services/README.md b/infra/services/README.md
index 55b4c2e06b..8e574bf0d2 100644
--- a/infra/services/README.md
+++ b/infra/services/README.md
@@ -4,26 +4,19 @@
Generally our services (including museum itself) follow the same pattern:
-- They're run on vanilla Ubuntu instances. The only expectation they have is
- for Docker to be installed.
+- They're run on vanilla Ubuntu instances. The only expectation they have is for Docker to be installed.
-- They log to fixed, known, locations - `/root/var/log/foo.log` - so that
- these logs can get ingested by Promtail if needed.
+- They log to fixed, known, locations - `/root/var/log/foo.log` - so that these logs can get ingested by Promtail if needed.
-- Each service should consist of a Docker image (or a Docker compose file),
- and a systemd unit file.
+- Each service should consist of a Docker image (or a Docker compose file), and a systemd unit file.
-- To start / stop / schedule the service, we use systemd.
+- To start / stop / schedule the service, we use systemd.
-- Each time the service runs it should pull the latest Docker image, so there
- is no separate installation/upgrade step needed. We can just restart the
- service, and it'll use the latest code.
+- Each time the service runs it should pull the latest Docker image, so there is no separate installation/upgrade step needed. We can just restart the service, and it'll use the latest code.
-- Any credentials and/or configuration should be read by mounting the
- appropriate file from `/root/service-name` into the running Docker
- container.
+- Any credentials and/or configuration should be read by mounting the appropriate file from `/root/service-name` into the running Docker container.
-- There are exceptions to this general pattern (See [sentry](sentry)).
+- There are exceptions to this general pattern (See [sentry](sentry)).
## Systemd cheatsheet
@@ -37,20 +30,16 @@ sudo journalctl --unit my-service
## Adding a service
-Create a systemd unit file (See the various `*.service` files in this repository
-for examples).
+Create a systemd unit file (See the various `*.service` files in this repository for examples).
-If we want the service to start on boot, add an `[Install]` section to its
-service file (_note_: starting on boot requires one more step later):
+If we want the service to start on boot, add an `[Install]` section to its service file (_note_: starting on boot requires one more step later):
```
[Install]
WantedBy=multi-user.target
```
-Copy the service file to the instance where we want to run the service. Services
-might also have some additional configuration or env files, also copy those to
-the instance.
+Copy the service file to the instance where we want to run the service. Services might also have some additional configuration or env files, also copy those to the instance.
```sh
scp services/example.service example.env <instance>:
@@ -62,16 +51,14 @@ SSH into the instance.
ssh <instance>
```
-Move the service `/etc/systemd/service`, and any config files to their expected
-place. env and other config files that contain credentials are kept in `/root`.
+Move the service `/etc/systemd/service`, and any config files to their expected place. env and other config files that contain credentials are kept in `/root`.
```sh
sudo mv example.service /etc/systemd/system
sudo mv example.env /root
```
-If you want to start the service on boot (as spoken of in the `[Install]`
-section above), then enable it (this only needs to be done once):
+If you want to start the service on boot (as spoken of in the `[Install]` section above), then enable it (this only needs to be done once):
```sh
sudo systemctl enable service
@@ -97,19 +84,12 @@ sudo journalctl --follow --unit example
## Logging
-Simple services can log to their standard output: these are captured by Docker,
-and by default promtail is setup to injest Docker logs and send them to Grafana.
+Simple services can log to their standard output: these are captured by Docker, and by default promtail is setup to injest Docker logs and send them to Grafana.
One issue with the above simple setup is that we cannot attach job names.
-If the service needs to to attach a specific job name, or if the service wants
-more control over the log retention etc, then then services can log to to its
-own files.
+If the service needs to to attach a specific job name, or if the service wants more control over the log retention etc, then then services can log to to its own files.
-* Such files should be in `/var/logs` within the container, and this should be
- mounted to `/root/var/logs` on the instance (using the `-v` flag in the
- service file which launches the Docker container or the Docker compose cluster).
+- Such files should be in `/var/logs` within the container, and this should be mounted to `/root/var/logs` on the instance (using the `-v` flag in the service file which launches the Docker container or the Docker compose cluster).
-* There should be entry for this log file in the `promtail/promtail.yaml` on
- that instance. The logs will then get scraped by Promtail and sent over to
- Grafana.
+- There should be entry for this log file in the `promtail/promtail.yaml` on that instance. The logs will then get scraped by Promtail and sent over to Grafana.
diff --git a/infra/services/grafana/README.md b/infra/services/grafana/README.md
index 5c9ef8ef96..70f7df80b0 100644
--- a/infra/services/grafana/README.md
+++ b/infra/services/grafana/README.md
@@ -1,7 +1,6 @@
# Grafana
-Grafana data is stored in a persistent Docker volume named `grafana-storage`. To
-create a backup of this, use
+Grafana data is stored in a persistent Docker volume named `grafana-storage`. To create a backup of this, use
```sh
docker run --rm \
diff --git a/infra/services/listmonk/README.md b/infra/services/listmonk/README.md
index e94c676cd4..d62346a346 100644
--- a/infra/services/listmonk/README.md
+++ b/infra/services/listmonk/README.md
@@ -2,11 +2,9 @@
We use [Listmonk](https://listmonk.app/) to manage our mailing lists.
-- Museum lets Listmonk know about new users and account deletion (this allows
- Listmonk to create corresponding accounts).
+- Museum lets Listmonk know about new users and account deletion (this allows Listmonk to create corresponding accounts).
-- Subsequently, Listmonk handles user subscription / unsubscription etc
- (Listmonk stores its data in an external Postgres).
+- Subsequently, Listmonk handles user subscription / unsubscription etc (Listmonk stores its data in an external Postgres).
## Installing
@@ -28,9 +26,7 @@ sudo mv listmonk.service /etc/systemd/system/
sudo mv listmonk.nginx.conf /root/nginx/conf.d
```
-> The very first time we ran Listmonk, at this point we also needed to get it to
-> install the tables it needs in the Postgres DB. For this, we used the
-> `initialize-db.sh` script.
+> The very first time we ran Listmonk, at this point we also needed to get it to install the tables it needs in the Postgres DB. For this, we used the `initialize-db.sh` script.
>
> ```sh
> scp services/listmonk/initialize-db.sh <instance>:
@@ -39,8 +35,7 @@ sudo mv listmonk.nginx.conf /root/nginx/conf.d
> rm initialize-db.sh
> ```
-Tell systemd to pick up new service definitions, enable the unit (so that it
-automatically starts on boot), and start it this time around.
+Tell systemd to pick up new service definitions, enable the unit (so that it automatically starts on boot), and start it this time around.
```sh
sudo systemctl daemon-reload
diff --git a/infra/services/metabase/README.md b/infra/services/metabase/README.md
index 3ac8e1fcc6..b014264250 100644
--- a/infra/services/metabase/README.md
+++ b/infra/services/metabase/README.md
@@ -1,7 +1,6 @@
# Metabase
-Use the embedded H2 database (this db contains users, saved queries etc). The
-database is a mounted as a file from the local filesystem into the container.
+Use the embedded H2 database (this db contains users, saved queries etc). The database is a mounted as a file from the local filesystem into the container.
To take backups, backup `/root/metabase.db`
@@ -19,8 +18,7 @@ and reload the nginx service.
## Update
-Take a DB backup (just for safety), then restart the service (it'll pull the
-latest image).
+Take a DB backup (just for safety), then restart the service (it'll pull the latest image).
```sh
sudo systemctl stop metabase
diff --git a/infra/services/nginx/README.md b/infra/services/nginx/README.md
index f72547896d..497b5a30cb 100644
--- a/infra/services/nginx/README.md
+++ b/infra/services/nginx/README.md
@@ -1,8 +1,6 @@
# Nginx
-This is a base Nginx service that terminates TLS, and can be used as a reverse
-proxy for arbitrary services by adding new entries in `/root/nginx/conf.d` and
-`sudo systemctl reload nginx`.
+This is a base Nginx service that terminates TLS, and can be used as a reverse proxy for arbitrary services by adding new entries in `/root/nginx/conf.d` and `sudo systemctl reload nginx`.
## Installation
@@ -27,8 +25,7 @@ sudo tee /root/nginx/cert.pem
sudo tee /root/nginx/key.pem
```
-Tell systemd to pick up new service definition, enable it (so that it
-automatically starts on boot going forward), and start it.
+Tell systemd to pick up new service definition, enable it (so that it automatically starts on boot going forward), and start it.
```sh
sudo systemctl daemon-reload
@@ -45,8 +42,7 @@ When adding new services that sit behind Nginx,
## Configuration files
-All the files we put into `/root/nginx/conf.d` get included in an `http` block.
-We can see this in the default configuration of nginx:
+All the files we put into `/root/nginx/conf.d` get included in an `http` block. We can see this in the default configuration of nginx:
```
http {
@@ -55,21 +51,16 @@ http {
}
```
-> To view the default configuration, run the following command against the
-> [official Docker image for Nginx](https://hub.docker.com/_/nginx), which is
-> also what we use:
+> To view the default configuration, run the following command against the [official Docker image for Nginx](https://hub.docker.com/_/nginx), which is also what we use:
>
> docker run --rm --entrypoint=cat nginx /etc/nginx/nginx.conf > /tmp/nginx.conf
-This is a [handy tool](https://nginx-playground.wizardzines.com) to check the
-syntax of the configuration files. Alternatively, you can run `docker exec nginx
-nginx -t` on the instance to ask nginx to check the configuration.
+This is a [handy tool](https://nginx-playground.wizardzines.com) to check the syntax of the configuration files. Alternatively, you can run `docker exec nginx nginx -t` on the instance to ask nginx to check the configuration.
## Updating configuration
Nginx configuration files can be changed without needing to restart anything.
1. Update the configuration file at `/root/nginx/conf.d/museum.conf`
-2. Verify that there are no errors in the configuration by using `sudo docker
- exec nginx nginx -t`.
+2. Verify that there are no errors in the configuration by using `sudo docker exec nginx nginx -t`.
3. Ask nginx to reload the configuration `sudo systemctl reload nginx`.
diff --git a/infra/services/prometheus/README.md b/infra/services/prometheus/README.md
index 8f05f7fb9b..91677cb9cf 100644
--- a/infra/services/prometheus/README.md
+++ b/infra/services/prometheus/README.md
@@ -1,18 +1,12 @@
# Prometheus
-Install `prometheus.service` on an instance if it is running something that
-exports custom Prometheus metrics. In particular, museum does.
+Install `prometheus.service` on an instance if it is running something that exports custom Prometheus metrics. In particular, museum does.
-If it is an instance whose metrics (CPU, disk, RAM etc) we want to monitor, also
-install `node-exporter.service` after installing
-[node-exporter](https://prometheus.io/docs/guides/node-exporter/) itself (Note
-that our prepare-instance script already installs node-exporter) .
+If it is an instance whose metrics (CPU, disk, RAM etc) we want to monitor, also install `node-exporter.service` after installing [node-exporter](https://prometheus.io/docs/guides/node-exporter/) itself (Note that our prepare-instance script already installs node-exporter) .
## Installing
-Prometheus doesn't currently support environment variables in config file, so
-remember to change the hardcoded `XX-HOSTNAME` too in addition to adding the
-`remote_write` configuration.
+Prometheus doesn't currently support environment variables in config file, so remember to change the hardcoded `XX-HOSTNAME` too in addition to adding the `remote_write` configuration.
```sh
scp services/prometheus/prometheus.* <instance>:
@@ -24,8 +18,7 @@ sudo mv prometheus.service /etc/systemd/system/prometheus.service
sudo mv node-exporter.service /etc/systemd/system/node-exporter.service
```
-Tell systemd to pick up new service definitions, enable the units (so that they
-automatically start on boot going forward), and start them.
+Tell systemd to pick up new service definitions, enable the units (so that they automatically start on boot going forward), and start them.
```sh
sudo systemctl daemon-reload
diff --git a/infra/services/promtail/README.md b/infra/services/promtail/README.md
index 9a12b10c33..63f6d5382e 100644
--- a/infra/services/promtail/README.md
+++ b/infra/services/promtail/README.md
@@ -1,12 +1,10 @@
# Promtail
-Install `promtail.service` on an instance if it is running something whose logs
-we want in Grafana.
+Install `promtail.service` on an instance if it is running something whose logs we want in Grafana.
## Installing
-Replace `client.url` in the config file with the Loki URL that Promtail should
-connect to, and move the files to their expected place.
+Replace `client.url` in the config file with the Loki URL that Promtail should connect to, and move the files to their expected place.
```sh
scp services/promtail/promtail.* <instance>:
@@ -16,8 +14,7 @@ sudo mv promtail.yaml /root/promtail.yaml
sudo mv promtail.service /etc/systemd/system/promtail.service
```
-Tell systemd to pick up new service definitions, enable the unit (so that it
-automatically starts on boot), and start it this time around.
+Tell systemd to pick up new service definitions, enable the unit (so that it automatically starts on boot), and start it this time around.
```sh
sudo systemctl daemon-reload
diff --git a/infra/services/sentry/README.md b/infra/services/sentry/README.md
index a852feb613..230868a8d5 100644
--- a/infra/services/sentry/README.md
+++ b/infra/services/sentry/README.md
@@ -1,62 +1,39 @@
# Sentry
-- [Data flow](#understanding-the-data-flow)
-- [Setting up a new instance](#setting-up-a-new-instance)
+- [Data flow](#understanding-the-data-flow)
+- [Setting up a new instance](#setting-up-a-new-instance)
## Data flow
### Overview
-Clients tunnel events to sentry-reporter.ente.io, and include the DSN in the
-request. At the other end of the tunnel is a Cloudflare Worker which unwraps the
-event, remaps the DSN if needed, and sends it to our actual self-hosted Sentry
-instance, sentry.ente.io.
+Clients tunnel events to sentry-reporter.ente.io, and include the DSN in the request. At the other end of the tunnel is a Cloudflare Worker which unwraps the event, remaps the DSN if needed, and sends it to our actual self-hosted Sentry instance, sentry.ente.io.
-Among other things, this indirection allows us to treat the Sentry instance as
-disposable, and recreate it from scratch anytime. The existing DSN's change, but
-that is not a problem because we remap DSNs in the worker that handles the
-tunneled requests.
+Among other things, this indirection allows us to treat the Sentry instance as disposable, and recreate it from scratch anytime. The existing DSN's change, but that is not a problem because we remap DSNs in the worker that handles the tunneled requests.
### DSN
-Sentry identifies each project with a unique ID it calls **DSN** (Data Source
-Name). The DSN is a URL that includes the project ID. For example, here is the
-DSN for the debug builds of the photos mobile app:
+Sentry identifies each project with a unique ID it calls **DSN** (Data Source Name). The DSN is a URL that includes the project ID. For example, here is the DSN for the debug builds of the photos mobile app:
-The DSN is considered public information and is included as part of the client's
-code. The DSN has 3 parts:
+The DSN is considered public information and is included as part of the client's code. The DSN has 3 parts:
https://<public-key-for-project>@<host>/<project-id>
The `<host>` for our case is sentry.ente.io.
-Each client has a separate project, and some clients have multiple projects
-(e.g. production / debug). Each of these get a separate DSN.
+Each client has a separate project, and some clients have multiple projects (e.g. production / debug). Each of these get a separate DSN.
### Reporting crashes
-Sentry supports
-[tunnels](https://docs.sentry.io/platforms/javascript/configuration/options/#tunnel).
-The idea is to encapsulate the entire "original" HTTP event which would've been
-reported to some Sentry instance, and instead send this encapsulated event to a
-URL that is hosted alongside the app itself (say, example.org/sentry). At the
-other end of the tunnel is a service that unwraps the original payload and
-forwards it to the actual Sentry instance.
+Sentry supports [tunnels](https://docs.sentry.io/platforms/javascript/configuration/options/#tunnel). The idea is to encapsulate the entire "original" HTTP event which would've been reported to some Sentry instance, and instead send this encapsulated event to a URL that is hosted alongside the app itself (say, example.org/sentry). At the other end of the tunnel is a service that unwraps the original payload and forwards it to the actual Sentry instance.
-Usage on the client is simple - the mobile SDKs for Sentry support a `tunnel`
-parameter which can be set to "https://sentry-reporter.ente.io"
+Usage on the client is simple - the mobile SDKs for Sentry support a `tunnel` parameter which can be set to "https://sentry-reporter.ente.io"
-The other end of the tunnel is handled by a Cloudflare Worker that listens for
-incoming requests to 'https://sentry-reporter.ente.io', and forwards the
-requests to `sentry.ente.io`. Before forwarding, it also remaps the DSNs sent by
-the client with the latest ones. This allows us to hardcode the DSN in the
-client - if the DSN on the Sentry backend changes, we can just update or add a
-new mapping in the worker.
+The other end of the tunnel is handled by a Cloudflare Worker that listens for incoming requests to 'https://sentry-reporter.ente.io', and forwards the requests to `sentry.ente.io`. Before forwarding, it also remaps the DSNs sent by the client with the latest ones. This allows us to hardcode the DSN in the client - if the DSN on the Sentry backend changes, we can just update or add a new mapping in the worker.
-The source code for this worker is in
-[workers/sentry-reporter](../../workers/sentry-reporter).
+The source code for this worker is in [workers/sentry-reporter](../../workers/sentry-reporter).
## Setting up a new instance
@@ -64,77 +41,77 @@ The source code for this worker is in
The upstream documentation is at https://develop.sentry.dev/self-hosted/.
-We follow their steps (clone their setup, modify the configuration, and run the
-`./install.sh` that they provide). This results in a Sentry installation being
-available at localhost:9000.
+We follow their steps (clone their setup, modify the configuration, and run the `./install.sh` that they provide). This results in a Sentry installation being available at localhost:9000.
-Then, we install an nginx service that terminates the Cloudflare TLS and reverse
-proxies to localhost:9000.
+Then, we install an nginx service that terminates the Cloudflare TLS and reverse proxies to localhost:9000.
To update Sentry just fetch the latest upstream and re-run `./install.sh`.
### Steps
-> The following assumes that you have already provisioned new instances using
-> our standard process.
+> The following assumes that you have already provisioned new instances using our standard process.
-- `cd /home/ente && git clone https://github.com/getsentry/self-hosted sentry`
-- Checkout the latest tag, e.g. `git checkout 24.2.0` (Sentry uses CalVer, so
- this'll be the latest `year.month.0`)
-- Run `sudo ./install.sh`
+- `cd /home/ente && git clone https://github.com/getsentry/self-hosted sentry`
+- Checkout the latest tag, e.g. `git checkout 24.2.0` (Sentry uses CalVer, so this'll be the latest `year.month.0`)
+- Run `sudo ./install.sh`
The rest of this section describes the remaining three steps:
-- Modify configuration
-- Configure and start external nginx
-- Start the cluster
+- Modify configuration
+- Configure and start external nginx
+- Start the cluster
### Configuration
-Modify `sentry/config.yml`, adding relevant bits from the contents of
-`config.yml` (from this repository) and the mail credentials.
+Modify `sentry/config.yml`, adding relevant bits from the contents of `config.yml` (from this repository) and the mail credentials.
Next, modify `.env`, setting
- SENTRY_EVENT_RETENTION_DAYS=30
- SENTRY_MAIL_HOST=ente.io
+```dotenv
+SENTRY_EVENT_RETENTION_DAYS=30
+SENTRY_MAIL_HOST=ente.io
+```
### Configure external nginx
-Add the nginx service (See [services/nginx](../services/nginx/README.md)) to the
-instance.
+Add the nginx service (See [services/nginx](../services/nginx/README.md)) to the instance.
-Add the Sentry nginx conf and certificates (since this instance will be running
-only sentry, we can use sentry specific certificates instead of our general
-wildcard ones).
+Add the Sentry nginx conf and certificates (since this instance will be running only sentry, we can use sentry specific certificates instead of our general wildcard ones).
- sudo mv sentry.nginx.conf /root/nginx/conf.d
- sudo tee /root/nginx/cert.pem
- sudo tee /root/nginx/key.pem
+```sh
+sudo mv sentry.nginx.conf /root/nginx/conf.d
+sudo tee /root/nginx/cert.pem
+sudo tee /root/nginx/key.pem
+```
### Start Sentry
-Sentry should automatically start when the instance boots. If needed (and for
-the first time), it can be started manually by
+Sentry should automatically start when the instance boots. If needed (and for the first time), it can be started manually by
- cd /home/ente/sentry
- sudo docker compose up -d
+```sh
+cd /home/ente/sentry
+sudo docker compose up -d
+```
-The (external) nginx service will also start automatically on boot, but
-if neded it can be manually started by
+The (external) nginx service will also start automatically on boot, but if neded it can be manually started by
- sudo systemctl start nginx
+```sh
+sudo systemctl start nginx
+```
-In their docs Sentry sometimes refers to commands like `sentry createuser`. To
-run them, prefix the command with `docker compose exec web`. e.g.
+In their docs Sentry sometimes refers to commands like `sentry createuser`. To run them, prefix the command with `docker compose exec web`. e.g.
- cd /home/ente/sentry
- sudo docker compose exec web sentry createuser
+```sh
+cd /home/ente/sentry
+sudo docker compose exec web sentry createuser
+```
If needed, Sentry can be stopped by using
- cd /home/ente/sentry
- sudo docker compose stop
+```sh
+cd /home/ente/sentry
+sudo docker compose stop
+```
## Backup / Restore
@@ -156,8 +133,7 @@ sentry/config.yml
.env
```
-To restore, run the fresh install. Once it completes, add our custom config
-back, ensuring we don't overwrite anything that the new version has
+To restore, run the fresh install. Once it completes, add our custom config back, ensuring we don't overwrite anything that the new version has
```sh
git diff --no-index ../.env .env
diff --git a/infra/services/status/README.md b/infra/services/status/README.md
index 78446947f7..3137ee80bb 100644
--- a/infra/services/status/README.md
+++ b/infra/services/status/README.md
@@ -1,15 +1,12 @@
# Status
-Our status page ([status.ente.com](https://status.ente.com)) is a self-hosted
-[Uptime Kuma](https://github.com/louislam/uptime-kuma).
+Our status page ([status.ente.com](https://status.ente.com)) is a self-hosted [Uptime Kuma](https://github.com/louislam/uptime-kuma).
## Installing
Install [nginx](../nginx/README.md).
-Create a directory where Uptime Kuma will keep its state. This is the directory
-we can optionally backup if we wish to preserve history and settings when moving
-instances in the future.
+Create a directory where Uptime Kuma will keep its state. This is the directory we can optionally backup if we wish to preserve history and settings when moving instances in the future.
```sh
sudo mkdir -p /root/uptime-kuma
@@ -24,8 +21,7 @@ sudo mv uptime-kuma.service /etc/systemd/system/
sudo mv uptime-kuma.nginx.conf /root/nginx/conf.d
```
-Tell systemd to pick up new service definitions, enable the unit (so that it
-automatically starts on boot), and start it this time around.
+Tell systemd to pick up new service definitions, enable the unit (so that it automatically starts on boot), and start it this time around.
```sh
sudo systemctl daemon-reload
diff --git a/infra/workers/README.md b/infra/workers/README.md
index 39791b6ded..01ae59859c 100644
--- a/infra/workers/README.md
+++ b/infra/workers/README.md
@@ -1,34 +1,26 @@
# Cloudflare Workers
-Source code for our
-[Cloudflare Workers](https://developers.cloudflare.com/workers/).
+Source code for our [Cloudflare Workers](https://developers.cloudflare.com/workers/).
-Workers are organized as Yarn workspaces sharing a common `package.json` and
-base `tsconfig`. They can however be deployed individually.
+Workers are organized as Yarn workspaces sharing a common `package.json` and base `tsconfig`. They can however be deployed individually.
## Deploying
Install dependencies with `yarn`.
-> If you have previously deployed, then you will have an old `yarn.lock`. In
-> this case it is safe to delete and recreate using `rm yarn.lock && yarn`.
+> If you have previously deployed, then you will have an old `yarn.lock`. In this case it is safe to delete and recreate using `rm yarn.lock && yarn`.
Then, to deploy an individual worker
-- Login into wrangler (if needed) using
- `yarn workspace health-check wrangler login`
+- Login into wrangler (if needed) using `yarn workspace health-check wrangler login`
- Deploy! `yarn workspace health-check wrangler deploy`
-Wrangler is the CLI provided by Cloudflare to manage workers. Apart from
-deploying, it also allows us to stream logs from running workers by using
-`yarn workspace <worker-name> wrangler tail`.
+Wrangler is the CLI provided by Cloudflare to manage workers. Apart from deploying, it also allows us to stream logs from running workers by using `yarn workspace <worker-name> wrangler tail`.
## Creating a new worker
-Copy paste an existing one. Unironically this is a good option because
-Cloudflare's template has a lot of unnecessary noise, but if really do want to
-create one from scratch, use `npm create cloudflare@latest`.
+Copy paste an existing one. Unironically this is a good option because Cloudflare's template has a lot of unnecessary noise, but if really do want to create one from scratch, use `npm create cloudflare@latest`.
To import an existing worker from the Cloudflare dashboard, use
@@ -42,5 +34,4 @@ Attach the tail worker to your worker by adding
tail_consumers = [{ service = "tail" }]
-in its `wrangler.toml`. Then any `console.(log|warn|error)` statements and
-uncaught exceptions in your worker will be logged to Grafana.
+in its `wrangler.toml`. Then any `console.(log|warn|error)` statements and uncaught exceptions in your worker will be logged to Grafana.