Embra-Connect-ETL / Embra-Connect-ETL/Development
Unify service ports
- Dominant language
- JavaScript
- Stars
- 0
- Forks
- 1
- PR merge metrics
- No merged PRs in 30d
Description
# Port Allocation and Configuration for Embra Connect APIs
This document outlines the reserved port configuration for various modules of the Embra Connect platform. The goal is to ensure consistent and conflict-free port usage.
----------
## **Reserved Ports**
Below is the list of reserved ports for specific modules within Embra Connect:
`generic-auth-module` - `9000`
`connect_ide` - `7000`
`landing` - `8000`
----------
## **Dynamic Configuration**
To ensure these ports are dynamically set up during application runtime, the following guidelines and methods can be used:
### **Rocket Configuration**
1. **Static Assignment in `Rocket.toml`**
- Define the ports explicitly in the configuration file for each environment:
```toml
[default]
address = "0.0.0.0"
[generic-auth-module]
port = 9000
[connect_ide]
port = 7000
[landing]
port = 8000
```
2. **Dynamic Port Assignment in Code** Use Rocket's `Config` struct to set the port programmatically for each module.
#### Example for `generic-auth-module`:
```rust
use rocket::{Config, Rocket};
#[rocket::main]
async fn main() {
let config = Config {
port: 9000,
address: "0.0.0.0".parse().expect("Invalid IP address"),
..Config::default()
};
let _ = rocket::custom(config)
.mount("/", rocket::routes![index])
.launch()
.await;
}
#[rocket::get("/")]
fn index() -> &'static str {
"Auth Module is running on port 9000!"
}
```
----------
## **General Guidelines**
### **Avoiding Port Conflicts**
1. Ensure the reserved ports are excluded from the OS ephemeral port range.
- On **Linux**, adjust the ephemeral port range:
```bash
echo "8001 65535" > /proc/sys/net/ipv4/ip_local_port_range
```
- On **Windows**:
```cmd
netsh int ipv4 set dynamicport tcp start=8001 num=57535
```
2. Monitor port usage to avoid accidental conflicts. Use tools like `lsof` or `netstat` to identify processes using reserved ports.
### **Testing Reserved Ports**
Before launching each module, ensure the port is available:
```bash
reserved_ports=(9000 7000 8000)
for port in "${reserved_ports[@]}"; do
if lsof -i:"$port" > /dev/null; then
echo "Port $port is already in use. Exiting."
exit 1
else
echo "Port $port is free."
fi
done
```
### **Containerized Deployment**
- Map the reserved ports explicitly when deploying in Docker or Kubernetes:
- **Docker Compose**:
```yaml
services:
auth-module:
ports:
- "9000:9000"
connect-ide:
ports:
- "7000:7000"
landing:
ports:
- "8000:8000"
```
----------
## **Future Expansion**
If additional modules are added to Embra Connect, assign ports from a dedicated high-numbered range (e.g., 8100-8200) and update this document accordingly.
Contributor guide
Assessment
This issue has not been assessed yet.