Skip to content

Commit 1907374

Browse files
committed
Update doc
1 parent 1c3c876 commit 1907374

File tree

6 files changed

+746
-270
lines changed

6 files changed

+746
-270
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Server-Worker Network Setup Guide
2+
3+
## System Components
4+
5+
### 1. Server (server.py)
6+
7+
```python
8+
from ceylon import Admin
9+
10+
app = Admin(name="admin", port=8888, role="admin")
11+
12+
13+
@app.on_run()
14+
async def run_worker(inputs: bytes):
15+
while True:
16+
await app.broadcast_message("Hello World from Server")
17+
```
18+
19+
The server broadcasts messages continuously to all connected workers.
20+
21+
### 2. Worker (worker_agent.py)
22+
23+
```python
24+
from ceylon import Worker
25+
26+
worker = Worker(name="worker", port=8888, role="worker")
27+
28+
29+
@worker.on(str)
30+
async def on_message(agent_id: str, data: str, time: int):
31+
print(f"Received message from {agent_id}: {data} at {time}")
32+
```
33+
34+
The worker listens for and processes messages from the server.
35+
36+
### 3. Configuration (.ceylon_network)
37+
38+
```
39+
WORKSPACE_ID=default
40+
WORKSPACE_IP=127.0.0.1
41+
WORKSPACE_PEER=12D3KooWMrqMLuYL3vExw7qaBJRzjN43kkkZwqSxUog7oaQCmnFE
42+
WORKSPACE_PORT=8888
43+
```
44+
45+
## Setup Instructions
46+
47+
1. Start the Server:
48+
```bash
49+
python server.py
50+
```
51+
- Server creates .ceylon_network file with connection details
52+
- WORKSPACE_PEER is auto-generated unique identifier
53+
54+
2. Start Worker(s):
55+
```bash
56+
python worker_agent.py
57+
```
58+
- Worker reads .ceylon_network file
59+
- Connects to server using WORKSPACE_PEER
60+
61+
## Remote Connection Setup
62+
63+
1. Copy .ceylon_network to remote machine
64+
2. Update WORKSPACE_IP if needed
65+
3. Run worker_agent.py on remote machine
66+
67+
## Network Configuration
68+
69+
- Default port: 8888
70+
- Local IP: 127.0.0.1
71+
- For remote connections:
72+
- Update WORKSPACE_IP to server's IP
73+
- Ensure port 8888 is accessible
74+
75+
## Common Issues
76+
77+
1. Connection Failures
78+
- Verify .ceylon_network file exists
79+
- Check WORKSPACE_IP and port accessibility
80+
- Ensure WORKSPACE_PEER matches server
81+
82+
2. Network Constraints
83+
- Configure firewalls to allow port 8888
84+
- Use correct IP for non-local connections
85+
86+
## Security Notes
87+
88+
- WORKSPACE_PEER acts as unique identifier
89+
- Keep .ceylon_network secure for controlled access
90+
- Update configuration for production environments

0 commit comments

Comments
 (0)