Add documentation for db setup and more frequent save
This commit is contained in:
parent
5837285455
commit
67ae3ce5e2
|
@ -1,12 +1,11 @@
|
||||||
# Lox Distributor
|
# Lox Distributor
|
||||||
|
|
||||||
The Lox distributor receives resources from [rdsys](https://gitlab.torproject.org/tpo/anti-censorship/rdsys) and writes them to [Lox
|
The Lox distributor receives resources from [rdsys](https://gitlab.torproject.org/tpo/anti-censorship/rdsys) and writes them to [Lox
|
||||||
BridgeLines](https://git-crysp.uwaterloo.ca/iang/lox/src/master/src/bridge_table.rs#L42). Concurrently, it receives and responds to requests from [Lox clients](https://gitlab.torproject.org/tpo/anti-censorship/lox/lox-wasm).
|
BridgeLines](https://git-crysp.uwaterloo.ca/iang/lox/src/master/src/bridge_table.rs#L42). Concurrently, it receives and responds to requests from [Lox clients](https://gitlab.torproject.org/tpo/anti-censorship/lox/lox-wasm). It saves the [LoxContext](https://gitlab.torproject.org/tpo/anti-censorship/lox-rs/-/blob/main/crates/lox-distributor/src/lox_context.rs) to a database every time the Lox bridgetable is updated and before the distributor is shutdown.
|
||||||
|
|
||||||
## Configure rdsys stream
|
## Configure rdsys stream
|
||||||
|
|
||||||
A test `config.json` is included for testing on a local instance of rdsys. This
|
A test `config.json` is included for testing on a local instance of rdsys. This
|
||||||
can be edited to correspond to the desired types of resources and endpoints.
|
can be edited to correspond to the desired types of resources, endpoints and database configuration.
|
||||||
|
|
||||||
## Test Run
|
## Test Run
|
||||||
|
|
||||||
|
@ -26,6 +25,13 @@ Finally run rdsys:
|
||||||
./backend --config config.json
|
./backend --config config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Database Config
|
||||||
|
|
||||||
|
The database has a few configuration options. The path for where the database
|
||||||
|
should be read/written can be specified in the `config.json`. Rolling back to a
|
||||||
|
previous version of the database is also possible by passing the
|
||||||
|
`roll_back_date` flag at runtime and providing the date/time as a `%Y-%m-%d_%H:%M:%S` string. This argument should be passed if the `LoxContext` should be rolled back to a previous state due to, for example, a mass blocking event that is likely not due to Lox user behaviour. If the exact roll back date/time is not known, the last db entry within 24 hours from the passed `roll_back_date` will be used or else the program will fail gracefully.
|
||||||
|
|
||||||
### Run Lox Distributor locally
|
### Run Lox Distributor locally
|
||||||
|
|
||||||
Simply run `cargo run -- config.json` :)
|
Simply run `cargo run -- config.json` :)
|
||||||
|
|
|
@ -311,9 +311,11 @@ async fn context_manager(
|
||||||
if let Err(e) = sender.send(response) {
|
if let Err(e) = sender.send(response) {
|
||||||
eprintln!("Server Response Error: {:?}", e);
|
eprintln!("Server Response Error: {:?}", e);
|
||||||
};
|
};
|
||||||
|
lox_db.write_context(context.clone());
|
||||||
sleep(Duration::from_millis(1)).await;
|
sleep(Duration::from_millis(1)).await;
|
||||||
}
|
}
|
||||||
Shutdown { shutdown_sig } => {
|
Shutdown { shutdown_sig } => {
|
||||||
|
lox_db.write_context(context.clone());
|
||||||
println!("Sending Shutdown Signal, all threads should shutdown.");
|
println!("Sending Shutdown Signal, all threads should shutdown.");
|
||||||
drop(shutdown_sig);
|
drop(shutdown_sig);
|
||||||
println!("Shutdown Sent.");
|
println!("Shutdown Sent.");
|
||||||
|
|
Loading…
Reference in New Issue