mirror of
https://github.com/mudler/LocalAI.git
synced 2025-05-04 17:52:53 +00:00
feat(p2p): allow to disable DHT and use only LAN (#2751)
This allows LocalAI to be less noisy avoiding to connect outside. Needed if e.g. there is no plan into using p2p across separate networks. Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
parent
f120a0c9f9
commit
d5a56f04be
@ -348,11 +348,15 @@ func newNodeOpts(token string) ([]node.Option, error) {
|
|||||||
llger := logger.New(log.LevelFatal)
|
llger := logger.New(log.LevelFatal)
|
||||||
defaultInterval := 10 * time.Second
|
defaultInterval := 10 * time.Second
|
||||||
|
|
||||||
|
// TODO: move this up, expose more config options when creating a node
|
||||||
|
noDHT := os.Getenv("LOCALAI_P2P_DISABLE_DHT") == "true"
|
||||||
|
noLimits := os.Getenv("LOCALAI_P2P_DISABLE_LIMITS") == "true"
|
||||||
|
|
||||||
loglevel := "info"
|
loglevel := "info"
|
||||||
|
|
||||||
c := config.Config{
|
c := config.Config{
|
||||||
Limit: config.ResourceLimit{
|
Limit: config.ResourceLimit{
|
||||||
Enable: true,
|
Enable: !noLimits,
|
||||||
MaxConns: 100,
|
MaxConns: 100,
|
||||||
},
|
},
|
||||||
NetworkToken: token,
|
NetworkToken: token,
|
||||||
@ -372,7 +376,7 @@ func newNodeOpts(token string) ([]node.Option, error) {
|
|||||||
RateLimitInterval: defaultInterval,
|
RateLimitInterval: defaultInterval,
|
||||||
},
|
},
|
||||||
Discovery: config.Discovery{
|
Discovery: config.Discovery{
|
||||||
DHT: true,
|
DHT: noDHT,
|
||||||
MDNS: true,
|
MDNS: true,
|
||||||
Interval: 30 * time.Second,
|
Interval: 30 * time.Second,
|
||||||
},
|
},
|
||||||
|
@ -98,3 +98,14 @@ The server logs should indicate that new workers are being discovered.
|
|||||||
- If running in p2p mode with container images, make sure you start the container with `--net host` or `network_mode: host` in the docker-compose file.
|
- If running in p2p mode with container images, make sure you start the container with `--net host` or `network_mode: host` in the docker-compose file.
|
||||||
- Only a single model is supported currently.
|
- Only a single model is supported currently.
|
||||||
- Ensure the server detects new workers before starting inference. Currently, additional workers cannot be added once inference has begun.
|
- Ensure the server detects new workers before starting inference. Currently, additional workers cannot be added once inference has begun.
|
||||||
|
|
||||||
|
|
||||||
|
## Environment Variables
|
||||||
|
|
||||||
|
There are options that can be tweaked or parameters that can be set using environment variables
|
||||||
|
|
||||||
|
| Environment Variable | Description |
|
||||||
|
|----------------------|-------------|
|
||||||
|
| **LOCALAI_P2P_DISABLE_DHT** | Set to "true" to disable DHT and enable p2p layer to be local only (mDNS) |
|
||||||
|
| **LOCALAI_P2P_DISABLE_LIMITS** | Set to "true" to disable connection limits and resources management |
|
||||||
|
| **LOCALAI_P2P_TOKEN** | Set the token for the p2p network |
|
||||||
|
Loading…
x
Reference in New Issue
Block a user