From 92e30ddaa2d7f611e329ab9647aaa08367acf044 Mon Sep 17 00:00:00 2001 From: Jari Kolehmainen Date: Fri, 29 Jan 2021 12:08:37 +0200 Subject: [PATCH] fix ClusterManager cluster auto-init Signed-off-by: Jari Kolehmainen --- src/main/cluster-manager.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/cluster-manager.ts b/src/main/cluster-manager.ts index 1b468e3bb6..dfcda98203 100644 --- a/src/main/cluster-manager.ts +++ b/src/main/cluster-manager.ts @@ -1,7 +1,7 @@ import "../common/cluster-ipc"; import type http from "http"; import { ipcMain } from "electron"; -import { autorun } from "mobx"; +import { autorun, reaction } from "mobx"; import { clusterStore, getClusterIdFromHost } from "../common/cluster-store"; import { Cluster } from "./cluster"; import logger from "./logger"; @@ -12,14 +12,14 @@ export class ClusterManager extends Singleton { constructor(public readonly port: number) { super(); // auto-init clusters - autorun(() => { - clusterStore.enabledClustersList.forEach(cluster => { + reaction(() => clusterStore.enabledClustersList, (clusters) => { + clusters.forEach((cluster) => { if (!cluster.initialized && !cluster.initializing) { logger.info(`[CLUSTER-MANAGER]: init cluster`, cluster.getMeta()); cluster.init(port); } }); - }); + }, { fireImmediately: true }); // auto-stop removed clusters autorun(() => {