mirror of
https://github.com/mudler/LocalAI.git
synced 2026-03-31 21:25:59 -04:00
feat: standardize CLI flag naming to kebab-case with backwards compatibility - Rename --p2ptoken to --p2p-token for consistency - Add deprecation alias for old --p2ptoken flag - Fix broken name tag in config check command - Add runtime deprecation warning system (core/cli/deprecations.go) - Document kebab-case naming convention in code comments - Maintain full backwards compatibility via kong aliases Co-authored-by: localai-bot <localai-bot@noreply.github.com>
32 lines
1.3 KiB
Go
32 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
cliContext "github.com/mudler/LocalAI/core/cli/context"
|
|
"github.com/mudler/LocalAI/core/p2p"
|
|
"github.com/mudler/LocalAI/pkg/signals"
|
|
)
|
|
|
|
type FederatedCLI struct {
|
|
Address string `env:"LOCALAI_ADDRESS,ADDRESS" default:":8080" help:"Bind address for the API server" group:"api"`
|
|
Peer2PeerToken string `env:"LOCALAI_P2P_TOKEN,P2P_TOKEN,TOKEN" name:"p2p-token" aliases:"p2ptoken" help:"Token for P2P mode (optional; --p2ptoken is deprecated, use --p2p-token)" group:"p2p"`
|
|
RandomWorker bool `env:"LOCALAI_RANDOM_WORKER,RANDOM_WORKER" default:"false" help:"Select a random worker from the pool" group:"p2p"`
|
|
Peer2PeerNetworkID string `env:"LOCALAI_P2P_NETWORK_ID,P2P_NETWORK_ID" help:"Network ID for P2P mode, can be set arbitrarly by the user for grouping a set of instances." group:"p2p"`
|
|
TargetWorker string `env:"LOCALAI_TARGET_WORKER,TARGET_WORKER" help:"Target worker to run the federated server on" group:"p2p"`
|
|
}
|
|
|
|
func (f *FederatedCLI) Run(ctx *cliContext.Context) error {
|
|
warnDeprecatedFlags()
|
|
|
|
fs := p2p.NewFederatedServer(f.Address, p2p.NetworkID(f.Peer2PeerNetworkID, p2p.FederatedID), f.Peer2PeerToken, !f.RandomWorker, f.TargetWorker)
|
|
|
|
c, cancel := context.WithCancel(context.Background())
|
|
|
|
signals.RegisterGracefulTerminationHandler(func() {
|
|
cancel()
|
|
})
|
|
|
|
return fs.Start(c)
|
|
}
|