Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Commit

Permalink
Pass bovine_db_url hackily via config.json to os.environ
Browse files Browse the repository at this point in the history
Signed-off-by: John Andersen <[email protected]>
  • Loading branch information
pdxjohnny committed Oct 26, 2023
1 parent 03ba4fd commit 42b2569
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 8 additions & 6 deletions docs/federation_activitypub.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,12 @@ Populate Bob's federation config
```json
{
"handle_name": "bob",
"fqdn": "scitt.bob.chadig.com",
"workspace": "~/Documents/fediverse/scitt_federation_bob/",
"bovine_db_url": "~/Documents/fediverse/scitt_federation_bob/bovine.sqlite3",
"following": {
"alice": {
"actor_id": "alice@localhost:7000",
"domain": "http://localhost:7000"
"actor_id": "[email protected]",
}
}
}
Expand All @@ -140,7 +141,7 @@ Start the server
```console
$ rm -rf workspace_bob/
$ mkdir -p workspace_bob/storage/operations
$ BOVINE_DB_URL="sqlite://${HOME}/Documents/fediverse/scitt_federation_bob/bovine.sqlite3" scitt-emulator server \
$ scitt-emulator server \
--workspace ${HOME}/Documents/fediverse/scitt_federation_bob/workspace_bob/ --tree-alg CCF --port 6000 \
--middleware scitt_emulator.federation_activitypub_bovine:SCITTFederationActivityPubBovine \
--middleware-config-path ${HOME}/Documents/fediverse/scitt_federation_bob/config.json
Expand All @@ -155,11 +156,12 @@ Populate Alice's federation config
```json
{
"handle_name": "alice",
"fqdn": "scitt.alice.chadig.com",
"workspace": "~/Documents/fediverse/scitt_federation_alice/",
"bovine_db_url": "~/Documents/fediverse/scitt_federation_alice/bovine.sqlite3",
"following": {
"bob": {
"actor_id": "bob@localhost:6000",
"domain": "http://localhost:6000"
"actor_id": "[email protected]"
}
}
}
Expand All @@ -170,7 +172,7 @@ Start the server
```console
$ rm -rf workspace_alice/
$ mkdir -p workspace_alice/storage/operations
$ BOVINE_DB_URL="sqlite://${HOME}/Documents/fediverse/scitt_federation_alice/bovine.sqlite3" scitt-emulator server \
$ scitt-emulator server \
--workspace ${HOME}/Documents/fediverse/scitt_federation_alice/workspace_alice/ --tree-alg CCF --port 7000 \
--middleware scitt_emulator.federation_activitypub_bovine:SCITTFederationActivityPubBovine \
--middleware-config-path ${HOME}/Documents/fediverse/scitt_federation_alice/config.json
Expand Down
9 changes: 9 additions & 0 deletions scitt_emulator/federation_activitypub_bovine.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
import json
import types
Expand Down Expand Up @@ -47,6 +48,14 @@ def __init__(self, app, signals, config_path):
self.fqdn = self.config.get("fqdn", None)
self.workspace = Path(self.config["workspace"]).expanduser()

self.bovine_db_url = self.config.get("bovine_db_url", None)
if self.bovine_db_url and self.bovine_db_url.startswith("~"):
self.bovine_db_url = str(Path(self.bovine_db_url).expanduser())
# TODO Pass this as variable
if not "BOVINE_DB_URL" in os.environ and self.bovine_db_url:
os.environ["BOVINE_DB_URL"] = self.bovine_db_url
logging.debug(f"Set BOVINE_DB_URL to {self.bovine_db_url}")

BovinePubSub(app)
BovineHerd(app)

Expand Down

0 comments on commit 42b2569

Please sign in to comment.