iobroker.js-controller 6.0.5 → 6.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/lib/restart.ts"],
4
- "sourcesContent": ["import { spawn } from 'node:child_process';\nimport os from 'node:os';\nimport { getRootDir } from '@iobroker/js-controller-common-db/tools';\nimport path from 'node:path';\nimport url from 'node:url';\n\n/**\n * Restarts the js-controller\n *\n * @param callback callback to execute after restart is triggered\n */\nexport default function restart(callback?: () => void): void {\n let cmd;\n let args;\n if (os.platform() === 'win32') {\n // On Windows, we execute the controller entry point directly\n cmd = path.join(getRootDir(), 'iob.bat');\n args = ['restart'];\n } else {\n // Unix has a global iobroker binary that delegates to the init system\n // We need to call that, so we don't have two instances of ioBroker running\n cmd = 'iobroker';\n args = ['restart'];\n }\n const child = spawn(cmd, args, {\n detached: true,\n stdio: ['ignore', 'ignore', 'ignore'],\n windowsHide: true\n });\n child.unref();\n if (typeof callback === 'function') {\n setTimeout(() => callback(), 500);\n } else {\n setTimeout(() => process.exit(), 500);\n }\n}\n\n// eslint-disable-next-line unicorn/prefer-module\nconst modulePath = url.fileURLToPath(import.meta.url || 'file://' + __filename);\nif (process.argv[1] === modulePath) {\n restart();\n}\n"],
4
+ "sourcesContent": ["import { spawn } from 'node:child_process';\nimport os from 'node:os';\nimport { getRootDir } from '@iobroker/js-controller-common-db/tools';\nimport path from 'node:path';\nimport url from 'node:url';\n\n/**\n * Restarts the js-controller\n *\n * @param callback callback to execute after restart is triggered\n */\nexport default function restart(callback?: () => void): void {\n let cmd;\n let args;\n if (os.platform() === 'win32') {\n // On Windows, we execute the controller entry point directly\n cmd = path.join(getRootDir(), 'iob.bat');\n args = ['restart'];\n } else {\n // Unix has a global ioBroker binary that delegates to the init system\n // We need to call that, so we don't have two instances of ioBroker running\n cmd = 'iobroker';\n args = ['restart'];\n }\n const child = spawn(cmd, args, {\n detached: true,\n stdio: ['ignore', 'ignore', 'ignore'],\n windowsHide: true\n });\n child.unref();\n if (typeof callback === 'function') {\n setTimeout(() => callback(), 500);\n } else {\n setTimeout(() => process.exit(), 500);\n }\n}\n\n// eslint-disable-next-line unicorn/prefer-module\nconst modulePath = url.fileURLToPath(import.meta.url || 'file://' + __filename);\nif (process.argv[1] === modulePath) {\n restart();\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;gCAAsB;AACtB,qBAAe;AACf,mBAA2B;AAC3B,uBAAiB;AACjB,sBAAgB;AAJhB;AAWc,SAAP,QAAyB,UAAqB;AACjD,MAAI;AACJ,MAAI;AACJ,MAAI,eAAAA,QAAG,SAAQ,MAAO,SAAS;AAE3B,UAAM,iBAAAC,QAAK,SAAK,yBAAU,GAAI,SAAS;AACvC,WAAO,CAAC,SAAS;EACrB,OAAO;AAGH,UAAM;AACN,WAAO,CAAC,SAAS;EACrB;AACA,QAAM,YAAQ,iCAAM,KAAK,MAAM;IAC3B,UAAU;IACV,OAAO,CAAC,UAAU,UAAU,QAAQ;IACpC,aAAa;GAChB;AACD,QAAM,MAAK;AACX,MAAI,OAAO,aAAa,YAAY;AAChC,eAAW,MAAM,SAAQ,GAAI,GAAG;EACpC,OAAO;AACH,eAAW,MAAM,QAAQ,KAAI,GAAI,GAAG;EACxC;AACJ;AAGA,MAAM,aAAa,gBAAAC,QAAI,cAAc,YAAY,OAAO,YAAY,UAAU;AAC9E,IAAI,QAAQ,KAAK,OAAO,YAAY;AAChC,UAAO;AACX;",
6
6
  "names": ["os", "path", "url"]
7
7
  }
package/build/cjs/main.js CHANGED
@@ -2073,6 +2073,7 @@ async function processMessage(msg) {
2073
2073
  sendTo(msg.from, msg.command, { success: true }, msg.callback);
2074
2074
  } catch (e) {
2075
2075
  sendTo(msg.from, msg.command, { error: e.message, success: false }, msg.callback);
2076
+ return;
2076
2077
  }
2077
2078
  try {
2078
2079
  await listUpdatableOsPackages();
@@ -2080,6 +2081,7 @@ async function processMessage(msg) {
2080
2081
  logger.warn(`${hostLogPrefix} Could not check for new OS updates after upgrade: ${e.message}`);
2081
2082
  }
2082
2083
  if (restartRequired) {
2084
+ logger.info(`${hostLogPrefix} Restart js-controller because desired after package upgrade`);
2083
2085
  await (0, import_promises.setTimeout)(200);
2084
2086
  (0, import_restart.default)(() => !isStopping && stop(false));
2085
2087
  }