class CircusTrain {

  public static void main(String[] args) throws Exception {
    // below is output *before* logging is configured so will appear on console
    logVersionInfo();

    int exitCode = -1;
    try {
      String defaultModules = Joiner.on(",").join(Modules.REPLICATION, Modules.HOUSEKEEPING);
      exitCode = SpringApplication
          .exit(new SpringApplicationBuilder(CircusTrain.class)
              .properties("spring.config.location:${config:null}")
              .properties("spring.profiles.active:${modules:" + defaultModules + "}")
              .properties("instance.home:${user.home}")
              .properties("instance.name:${source-catalog.name}_${replica-catalog.name}")
              .properties("jasypt.encryptor.password:${password:null}")
              .properties("housekeeping.schema-name:circus_train")
              .registerShutdownHook(true)
              .initializers(new ExtensionInitializer())
              .listeners(new ConfigFileValidationApplicationListener())
              .build()
              .run(args));
    } catch (ConfigFileValidationException e) {
      LOG.error(e.getMessage(), e);
      printCircusTrainHelp(e.getErrors());
    } catch (BeanCreationException e) {
      LOG.error(e.getMessage(), e);
      Throwable mostSpecificCause = e.getMostSpecificCause();
      if (mostSpecificCause instanceof BindException) {
        printCircusTrainHelp(((BindException) mostSpecificCause).getAllErrors());
      }
    }

    System.exit(exitCode);
  }

    CircusTrain();

}