Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/stakwork/sphinx-swarm
Browse files Browse the repository at this point in the history
  • Loading branch information
Evanfeenstra committed Jun 19, 2024
2 parents cbeedb1 + d33eb85 commit c763d6b
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions src/bin/super/superapp/src/Remotes.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
Toolbar,
ToolbarContent,
ToolbarSearch,
ToolbarMenu,
ToolbarMenuItem,
} from "carbon-components-svelte";
import Healthcheck from "./Healthcheck.svelte";
import UploadIcon from "carbon-icons-svelte/lib/Upload.svelte";
Expand All @@ -27,8 +25,46 @@
tribes.set(serverTribes);
}
}
async function getConfigSortByUnhealthy() {
const conf = await api.swarm.get_config();
if (conf && conf.stacks && conf.stacks.length) {
let unhealthyRemotes = [];
let healthyRemotes = [];
for (let i = 0; i < conf.stacks.length; i++) {
let el = conf.stacks[i];
const host = el.host;
try {
let url = `https://boltwall.${host}/stats`;
// custom URLs
if (!url.includes("swarm")) {
url = `https://${host}/api/stats`;
}
console.log("URL", url);
const r = await fetch(url);
await r.json();
healthyRemotes.push(el);
} catch (e) {
console.warn(e);
unhealthyRemotes.push(el);
}
}
remotes.set([...unhealthyRemotes, ...healthyRemotes]);
const serverTribes = await getTribes([
...unhealthyRemotes,
...healthyRemotes,
]);
tribes.set(serverTribes);
}
}
onMount(() => {
getConfig();
const interval = setInterval(getConfigSortByUnhealthy, 3000);
getConfigSortByUnhealthy();
return () => clearInterval(interval);
});
function something() {
Expand Down

0 comments on commit c763d6b

Please sign in to comment.