MCPcopy
hub / github.com/Koenkk/zigbee2mqtt / start

Function start

index.js:129–161  ·  view source on GitHub ↗

@type {() => Promise }

()

Source from the content-addressed store, hash-verified

127
128/** @type {() => Promise<void>} */
129async function start() {
130 console.log(`Starting Zigbee2MQTT ${process.env.Z2M_WATCHDOG != null ? `with watchdog (${watchdogDelays})` : "without watchdog"}.`);
131 await checkDist();
132
133 // gc
134 {
135 const packageJSON = (await import("./package.json", {with: {type: "json"}})).default;
136 const version = packageJSON.engines.node;
137 const {satisfies} = await import("semver");
138
139 if (!satisfies(process.version, version)) {
140 console.log(`\t\tZigbee2MQTT requires node version ${version}, you are running ${process.version}!\n`);
141 }
142
143 const {onboard} = await import("./dist/util/onboarding.js");
144 const success = await onboard();
145
146 if (!success) {
147 unsolicitedStop = false;
148
149 return await exit(1);
150 }
151 }
152
153 const {Controller} = await import("./dist/controller.js");
154 controller = new Controller(restart, exit);
155
156 await controller.start();
157
158 // consider next controller.stop() call as unsolicited, only after successful first start
159 unsolicitedStop = true;
160 watchdogCount = 0; // reset
161}
162
163/** @type {(restart: boolean, signal?: NodeJS.Signals) => Promise<void>} */
164async function stop(restart, signal = undefined) {

Callers 3

triggerWatchdogFunction · 0.70
restartFunction · 0.70
index.jsFile · 0.70

Calls 5

checkDistFunction · 0.85
onboardFunction · 0.85
exitFunction · 0.85
logMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected