Merge pull request #2527 from abiliojr/test_config

broker: add command line argument to test configuration and exit
pull/2531/head
Roger Light 3 years ago committed by GitHub
commit 572e840b2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -55,6 +55,8 @@ Broker:
- Bridge reconnection backoff improvements.
- Add bridge_tls_use_os_certs option to allow bridges to be easily configured
to trust default CA certificates. Closes #2473.
- Add `--test-config` option which can be used to test a configuration file
before trying to use it in a live broker. Closes #2521.
Plugins / plugin interface:
- Add persist-sqlite plugin.

@ -387,9 +387,10 @@ static void print_usage(void)
printf(" Not recommended in conjunction with the -c option.\n");
printf(" -v : verbose mode - enable all logging types. This overrides\n");
printf(" any logging options given in the config file.\n");
printf(" --tls-keylog : Log TLS connection information to a file, to allow\n");
printf(" --tls-keylog : log TLS connection information to a file, to allow\n");
printf(" debugging with e.g. wireshark. Do not use on a production\n");
printf(" server.\n");
printf(" --test-config : test config file and exit\n");
printf("\nSee https://mosquitto.org/ for more information.\n\n");
}
@ -454,6 +455,8 @@ int config__parse_args(struct mosquitto__config *config, int argc, char *argv[])
#endif
}else if(!strcmp(argv[i], "-v") || !strcmp(argv[i], "--verbose")){
db.verbose = true;
}else if(!strcmp(argv[i], "--test-config")){
config->test_configuration = true;
}else{
fprintf(stderr, "Error: Unknown option '%s'.\n",argv[i]);
print_usage();

@ -264,6 +264,16 @@ int main(int argc, char *argv[])
rc = config__parse_args(&config, argc, argv);
if(rc != MOSQ_ERR_SUCCESS) return rc;
if(config.test_configuration){
if(!db.config_file){
log__printf(NULL, MOSQ_LOG_ERR, "Please provide a configuration file to test.");
return MOSQ_ERR_INVAL;
}else{
log__printf(NULL, MOSQ_LOG_INFO, "Configuration file is OK.");
return MOSQ_ERR_SUCCESS;
}
}
rc = keepalive__init();
if(rc != MOSQ_ERR_SUCCESS) return rc;

@ -306,6 +306,7 @@ struct mosquitto__config {
uint16_t cmd_port[CMD_PORT_LIMIT];
int cmd_port_count;
bool daemon;
bool test_configuration;
bool enable_control_api;
int global_max_clients;
int global_max_connections;

Loading…
Cancel
Save