retropilot-server/README-upstream.md

107 lines
3.9 KiB
Markdown
Raw Permalink Normal View History

2021-05-15 20:24:48 -06:00
# retropilot-server
2022-03-21 08:49:16 -06:00
2022-03-24 15:37:22 -06:00
![Uptime Robot status](https://img.shields.io/uptimerobot/status/m791143178-df355c13f922c35db89054b0)
![Uptime Robot ratio (7 days)](https://img.shields.io/uptimerobot/ratio/7/m791143178-df355c13f922c35db89054b0)
2022-03-21 08:49:16 -06:00
![CI workflow](https://github.com/RetroPilot/retropilot-server/actions/workflows/ci.yml/badge.svg)
2021-05-22 18:34:33 -06:00
Replacement for comma.ai backend and useradmin dashboard. Bundled with a modified version of comma's cabana to allow viewing & analyzing drives.
2021-05-21 20:22:33 -06:00
If you don't want to host your own instance, check out https://api.retropilot.org/useradmin for a hosted version of the backend, useradmin and cabana.
2021-05-15 22:03:50 -06:00
### [Server] Summary
2021-05-17 21:34:28 -06:00
The server consists of 2 node scripts.
2022-03-21 05:48:58 -06:00
- `src/server` is using expressjs and runs the backend (file upload / communication with openpilot) and the useradmin dashboard to manage / view / download drives & logs.
- `src/worker` is a background worker that is processing drives (analyzing video files & logs) to prepare drives for playback in cabana and to gather statistics. It automatically terminates itself after 60 minutes to make sure the video/log libraries do not cause memory leaks.
2021-05-15 22:03:50 -06:00
2021-05-17 21:34:28 -06:00
**Attention:** Minimum required node version is **node 10**.
2021-05-15 22:03:50 -06:00
### [Server] Installation
TODO: write instructions for PostgreSQL database
2021-05-15 22:03:50 -06:00
```
npm install
cp config.sample.js config.js
2021-05-17 21:34:28 -06:00
cp database.empty.sqlite database.sqlite
2021-05-15 22:03:50 -06:00
> EDIT config.js
```
### [Server] Running
```
node -r esm src/server
2021-05-15 22:03:50 -06:00
```
```
node -r esm src/worker
2021-05-15 22:03:50 -06:00
```
### [Server] CABANA Support
A compiled version of a custom cabana fork (https://github.com/RetroPilot/cabana) is directly bundled in the `cabana/` subdirectory and will be served by the express app. After starting `index.js`, cabana is ready to use.
2021-05-15 22:03:50 -06:00
-----
2021-06-05 08:07:53 -06:00
### [Device] Preparation / Enable Custom Server
2021-05-15 22:03:50 -06:00
2021-06-05 08:07:53 -06:00
On the device or in your fork's code, replace all API endpoints with your own server endpoint.
This could be executed directly on the device in the shell to use `https://api.retropilot.org` as backend:
2021-05-15 22:03:50 -06:00
```
2021-06-05 08:07:53 -06:00
find /data/openpilot -type f -exec sed -i 's/https:\/\/api.commadotai.com/https:\/\/api.retropilot.org/g' {} +
2021-05-15 22:03:50 -06:00
```
TODO: add git patch instructions
2021-06-05 08:07:53 -06:00
### [Device] Swapping Servers (Back)
To switch a device between different servers, you have to remove the old `DongleId` and reboot:
2021-06-05 08:07:53 -06:00
```
rm /data/params/d/DongleID
reboot
```
There is no need to backup the `DongleId`, as the new server will identify your device based on its imei, serial and public key.
### [Device] Raw Drives Not Uploading (fcamera & rlog)
2021-06-05 08:07:53 -06:00
1. Raw data is only uploaded if the device is sufficiently charged, not connected to an active panda (offroad) and there are no immediate files (boot, crash, qcamera, qlog) remaining.<br>
2. Your branch might have raw uploads disabled, check *Device Settings > Upload Raw Logs*.
2021-05-15 22:03:50 -06:00
2021-06-05 08:07:53 -06:00
If that doesn't help or the option is not available, try:
2021-05-15 22:03:50 -06:00
```
2021-06-05 08:07:53 -06:00
echo "1" > /data/params/d/IsUploadRawEnabled
echo "1" > /data/params/d/UploadRaw
2021-05-15 22:03:50 -06:00
reboot
```
2021-06-05 08:07:53 -06:00
-----
2021-05-15 22:03:50 -06:00
2021-06-05 08:07:53 -06:00
### Current Limitations
OpenPilot before 0.8.3 will not display any statistics or pairing status in the dashboard.
The reason is that pre 0.8.3, the `offroad.apk` with react and comma-api would require recompilation to accept the new endpoints.
2021-05-15 22:03:50 -06:00
2021-06-05 08:07:53 -06:00
The athena websockets interface is not implemented yet, so the comma app and athena specific remote control commands (including "upload on demand") are not functional as of now.
2021-05-15 22:03:50 -06:00
### Screenshots
![image](https://user-images.githubusercontent.com/48515354/118385101-6bd64780-b60c-11eb-899d-bcb0b32e2939.png)
![image](https://user-images.githubusercontent.com/48515354/118385092-4ba68880-b60c-11eb-987e-2ca801b56caa.png)
![image](https://user-images.githubusercontent.com/48515354/118385075-2a459c80-b60c-11eb-976c-bc331a609391.png)
![image](https://user-images.githubusercontent.com/48515354/118385084-37fb2200-b60c-11eb-8d3e-6db458827808.png)
2022-03-02 18:03:32 -07:00
## Deployment
2022-03-02 18:03:32 -07:00
For deployment instructions and configuration, take a look at the `environment` directory.