Skip to content

Commit

Permalink
Merge pull request #898 from mountaindude/870
Browse files Browse the repository at this point in the history
870
  • Loading branch information
mountaindude authored Dec 7, 2023
2 parents e6ef087 + 577dba3 commit 963827b
Show file tree
Hide file tree
Showing 17 changed files with 333 additions and 323 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ jobs:
with:
# command: manifest
# bootstrap-sha: ad2255c9c24f68d0adb5255159fa5a849ab880e4
last-release-sha: 849ed9960e22951f988050533ce1cf6e8ee29bb7
release-as: 9.3.0
# last-release-sha: 849ed9960e22951f988050533ce1cf6e8ee29bb7
# release-as: 9.3.0
release-type: node
package-name: butler
default-branch: master
Expand Down
47 changes: 14 additions & 33 deletions src/butler.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,39 +117,20 @@ const start = async () => {

// ------------------------------------
// Create MQTT client object and connect to MQTT broker, if MQTT is enabled
try {
await mqttInitHandlers();

// if (
// globals.config.has('Butler.mqttConfig.enable') &&
// globals.config.has('Butler.mqttConfig.brokerHost') &&
// globals.config.has('Butler.mqttConfig.brokerPort') &&
// globals.config.get('Butler.mqttConfig.enable')
// ) {
// const mqttOptions = {
// host: globals.config.get('Butler.mqttConfig.brokerHost'),
// port: globals.config.get('Butler.mqttConfig.brokerPort'),
// };

// globals.mqttClient = mqtt.connect(mqttOptions);
// /*
// Following might be needed for conecting to older Mosquitto versions
// var mqttClient = mqtt.connect('mqtt://<IP of MQTT server>', {
// protocolId: 'MQIsdp',
// protocolVersion: 3
// });
// */
// if (!globals.mqttClient.connected) {
// globals.logger.verbose(
// `CONFIG: Created (but not yet connected) MQTT object for ${mqttOptions.host}:${mqttOptions.port}, protocol version ${mqttOptions.protocolVersion}`
// );
// }
// } else {
// globals.logger.info('CONFIG: MQTT disabled, not connecting to MQTT broker');
// }
} catch (err) {
globals.logger.error(`CONFIG: Could not set up MQTT: ${JSON.stringify(err, null, 2)}`);
}
mqttInitHandlers();

// Sleep 5 seconds to allow MQTT to connect
globals.logger.info('MAIN: Sleeping 5 seconds to allow MQTT to connect.');
globals.logger.info('5...');
await globals.sleep(1000);
globals.logger.info('4...');
await globals.sleep(1000);
globals.logger.info('3...');
await globals.sleep(1000);
globals.logger.info('2...');
await globals.sleep(1000);
globals.logger.info('1...');
await globals.sleep(1000);

// Set up service monitoring, if enabled in the config file
if (globals.config.has('Butler.serviceMonitor.enable') && globals.config.get('Butler.serviceMonitor.enable') === true) {
Expand Down
14 changes: 7 additions & 7 deletions src/lib/config_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,35 @@ const configVerifyAllTaskId = () => {
try {
// Only verify allowed task IDs if that feature is turned on
if (globals.config.has('Butler.startTaskFilter.enable') && globals.config.get('Butler.startTaskFilter.enable') === true) {
globals.logger.info('CONFIG_VERIFY: Verifying that task IDs are valid...');
globals.logger.info('CONFIG VERIFY: Verifying that task IDs are valid...');

if (
globals.config.has('Butler.startTaskFilter.allowTask.taskId') === true &&
globals.config.get('Butler.startTaskFilter.allowTask.taskId')
) {
globals.config.get('Butler.startTaskFilter.allowTask.taskId').forEach((taskId) => {
if (guidRegExp.test(taskId) === true) {
globals.logger.verbose(`CONFIG_VERIFY: Allowed task ID is valid: ${taskId}`);
globals.logger.verbose(`CONFIG VERIFY: Allowed task ID is valid: ${taskId}`);
} else {
globals.logger.warn(`CONFIG_VERIFY: Allowed task ID not valid: ${taskId}`);
globals.logger.warn(`CONFIG VERIFY: Allowed task ID not valid: ${taskId}`);
}
});
}
}
} catch (err) {
globals.logger.error(`CONFIG_VERIFY: Error verifying all task IDs: ${err}`);
globals.logger.error(`CONFIG VERIFY: Error verifying all task IDs: ${err}`);
}
};

const verifyTaskId = (taskId) => {
try {
if (guidRegExp.test(taskId) === true) {
globals.logger.verbose(`TASKID_VERIFY: Task ID is valid: ${taskId}`);
globals.logger.verbose(`TASK ID VERIFY: Task ID is valid: ${taskId}`);
return true;
}
globals.logger.warn(`TASKID_VERIFY: Task ID not valid: ${taskId}`);
globals.logger.warn(`TASK ID VERIFY: Task ID not valid: ${taskId}`);
} catch (err) {
globals.logger.error(`TASKID_VERIFY: Error verifying task ID: ${err}`);
globals.logger.error(`TASK ID VERIFY: Error verifying task ID: ${err}`);
}
return false;
};
Expand Down
Loading

0 comments on commit 963827b

Please sign in to comment.