Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetching initial peers from env variables #12

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

filopedraz
Copy link
Contributor

Description

  • Updated config.py logic in order to get INITIAL_PEERS from env variable.
  • Updated documentation for monitoring self-hosted Swarm

Copy link
Member

@borzunov borzunov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@filopedraz, thanks for the PR!

Can we use spaces to separate INITIAL_PEERS? That's a convention we use throughout Petals code.

Please check if it works with the changes :)

ports:
- 5000:5000
environment:
- INITIAL_PEERS=/ip4/209.38.217.30/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6,/ip4/127.0.0.1/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- INITIAL_PEERS=/ip4/209.38.217.30/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6,/ip4/127.0.0.1/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6
- INITIAL_PEERS=/ip4/209.38.217.30/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6 /ip4/127.0.0.1/tcp/31337/p2p/QmecL18cmRaDdAcRmA7Ctj1gyAeUYG433WppA1UWTHTew6

@@ -6,4 +6,4 @@ services:
volumes:
- .:/usr/src/app
ports:
- "5000:5000"
- "5000:5000"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the diff minimal and revert this change :)

Comment on lines +6 to +11
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
INITIAL_PEERS = PUBLIC_INITIAL_PEERS
if value := os.getenv("INITIAL_PEERS"): # Override with the env variable if defined
INITIAL_PEERS = value.split()

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not super familiar with python, but redefining a constant like that seems unexpected

initial_peers_list = initial_peers_str.split(",") if initial_peers_str else []
if len(initial_peers_list) > 0:
INITIAL_PEERS = initial_peers_list
else:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggest moving from petals.constants import PUBLIC_INITIAL_PEERS into the else branch

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants