Skip to content

Commit 3457acc

Browse files
authored
chore(explorer): add join instructions (#3255)
* feat(explorer): give CLI instructions to join federated clusters Signed-off-by: Ettore Di Giacinto <[email protected]> * debug message Signed-off-by: Ettore Di Giacinto <[email protected]> --------- Signed-off-by: Ettore Di Giacinto <[email protected]>
1 parent f18862f commit 3457acc

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

core/http/views/explorer.html

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
color: #e2e8f0;
1010
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
1111
}
12+
.token {
13+
word-break: break-all;
14+
}
1215
.container {
1316
max-width: 800px;
1417
margin: 0 auto;
@@ -275,14 +278,28 @@ <h2 class="text-3xl font-bold mb-4"><i class="fa-solid fa-plus"></i> Add New Net
275278
<h2 class="text-3xl font-bold mb-4 mt-4">Available Clusters in this network</h2>
276279
<template x-for="cluster in network.Clusters" :key="cluster.NetworkID + cluster.Type">
277280
<div class="cluster">
278-
279281
<div class="cluster-title"></div>
280282
<span class="inline-block bg-orange-500 text-white py-1 px-3 rounded-full text-xs" x-text="'Cluster Type: ' + cluster.Type">
281283
</span>
284+
282285
<span class="inline-block bg-orange-500 text-white py-1 px-3 rounded-full text-xs" x-show="cluster.NetworkID" x-text="'Network ID: ' + (cluster.NetworkID || 'N/A')">
283286
</span>
284287
<span class="inline-block bg-blue-500 text-white py-1 px-3 rounded-full text-xs" x-text="'Number of Workers: ' + cluster.Workers.length">
285288
</span>
289+
<!-- Give commands and instructions to join the network -->
290+
<span class="inline-block token-box text-white py-1 px-3 text-xs" x-show="cluster.Type == 'federated'" >
291+
<p class="text-lg font-bold mb-4 mt-1">
292+
<i class="fa-solid fa-copy copy-icon float-right"></i>
293+
Command to connect (click to copy):
294+
</p>
295+
<code class="block bg-gray-700 text-yellow-300 p-4 rounded-lg break-words" @click="copyToken($el.textContent)" >
296+
docker run -d --restart=always -e ADDRESS=":80" -e LOCALAI_P2P_NETWORK_ID=<span class="token" x-text="cluster.NetworkID"></span> -e LOCALAI_P2P_LOGLEVEL=debug --name local-ai -e TOKEN="<span class="token" x-text="network.token"></span>" --net host -ti localai/localai:master-ffmpeg-core federated --debug
297+
</code>
298+
or via CLI:
299+
<code class="block bg-gray-700 text-yellow-300 p-4 rounded-lg break-words" @click="copyToken($el.textContent)" >
300+
ADDRESS=":80" LOCALAI_P2P_NETWORK_ID=<span class="token" x-text="cluster.NetworkID"></span> LOCALAI_P2P_LOGLEVEL=debug TOKEN="<span class="token" x-text="network.token"></span>" local-ai federated --debug
301+
</code>
302+
</span>
286303
</div>
287304
</template>
288305
</div>
@@ -361,8 +378,8 @@ <h2 class="text-3xl font-bold mb-4 mt-4">Available Clusters in this network</h2>
361378
copyToken(token) {
362379
navigator.clipboard.writeText(token)
363380
.then(() => {
364-
console.log('Token copied to clipboard:', token);
365-
alert('Token copied to clipboard!');
381+
console.log('Text copied to clipboard:', token);
382+
alert('Text copied to clipboard!');
366383
})
367384
.catch(err => {
368385
console.error('Failed to copy token:', err);

core/p2p/federated_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func (fs *FederatedServer) proxy(ctx context.Context, node *node.Node) error {
9898

9999
tunnelAddr = fs.SelectLeastUsedServer()
100100
if tunnelAddr == "" {
101+
log.Debug().Msgf("Least used server not found, selecting random")
101102
tunnelAddr = fs.RandomServer()
102103
}
103104

0 commit comments

Comments
 (0)