diff --git a/README.md b/README.md index 49f6417..aacc1a4 100644 --- a/README.md +++ b/README.md @@ -57,3 +57,16 @@ To monitor your private swarm instead of the public one, please replace `PUBLIC_ ```python INITIAL_PEERS = ['/ip4/10.1.2.3/tcp/31234/p2p/QmcXhze98AcgGQDDYna23s4Jho96n8wkwLJv78vxtFNq44'] ``` + +Or you can set the `INITIAL_PEERS` environment variable in the `docker-compose` as a comma separated list instead of editing the config file directly: + +```yaml +version: '3.7' +services: + app: + image: petals/health-monitor + ports: + - 5000:5000 + environment: + - INITIAL_PEERS=/ip4/209.38.217.30/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6,/ip4/127.0.0.1/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6 +``` diff --git a/config.py b/config.py index 3812066..87ec39c 100644 --- a/config.py +++ b/config.py @@ -1,9 +1,14 @@ +import os from petals.constants import PUBLIC_INITIAL_PEERS from data_structures import ModelInfo - -INITIAL_PEERS = PUBLIC_INITIAL_PEERS +initial_peers_str = os.getenv("INITIAL_PEERS") +initial_peers_list = initial_peers_str.split(",") if initial_peers_str else [] +if len(initial_peers_list) > 0: + INITIAL_PEERS = initial_peers_list +else: + INITIAL_PEERS = PUBLIC_INITIAL_PEERS MODELS = [ ModelInfo( diff --git a/docker-compose.yml b/docker-compose.yml index 198bd44..8ffb7a8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,4 +6,4 @@ services: volumes: - .:/usr/src/app ports: - - "5000:5000" + - "5000:5000" \ No newline at end of file