Starts the TSD. @param args The command line arguments
(String[] args)
| 309 | * @param args The command line arguments |
| 310 | */ |
| 311 | private static void launchTSD(String[] args) { |
| 312 | ConfigArgP cap = new ConfigArgP(args); |
| 313 | Config config = cap.getConfig(); |
| 314 | ArgP argp = cap.getArgp(); |
| 315 | applyCommandLine(cap, argp); |
| 316 | config.loadStaticVariables(); |
| 317 | // All options are now correctly set in config |
| 318 | setJVMName(config.getInt("tsd.network.port"), config.getString("tsd.network.bind")); |
| 319 | // Configure the logging |
| 320 | if(config.hasProperty("tsd.logback.file")) { |
| 321 | final String logBackFile = config.getString("tsd.logback.file"); |
| 322 | final String rollPattern = config.hasProperty("tsd.logback.rollpattern") ? config.getString("tsd.logback.rollpattern") : null; |
| 323 | final boolean keepConsoleOpen = config.hasProperty("tsd.logback.console") ? config.getBoolean("tsd.logback.console") : false; |
| 324 | log.info("\n\t===================================\n\tReconfiguring logback. Logging to file:\n\t{}\n\t===================================\n", logBackFile); |
| 325 | setLogbackInternal(logBackFile, rollPattern, keepConsoleOpen); |
| 326 | } else { |
| 327 | final String logBackConfig; |
| 328 | if(config.hasProperty("tsd.logback.config")) { |
| 329 | logBackConfig = config.getString("tsd.logback.config"); |
| 330 | } else { |
| 331 | logBackConfig = System.getProperty("tsd.logback.config", null); |
| 332 | } |
| 333 | if(logBackConfig!=null && !logBackConfig.trim().isEmpty() && new File(logBackConfig.trim()).canRead()) { |
| 334 | setLogbackExternal(logBackConfig.trim()); |
| 335 | } |
| 336 | } |
| 337 | if(config.auto_metric()) { |
| 338 | log.info("\n\t==========================================\n\tAuto-Metric Enabled\n\t==========================================\n"); |
| 339 | } else { |
| 340 | log.warn("\n\t==========================================\n\tAuto-Metric Disabled\n\t==========================================\n"); |
| 341 | } |
| 342 | try { |
| 343 | // Write the PID file |
| 344 | writePid(config.getString("tsd.process.pid.file"), config.getBoolean("tsd.process.pid.ignore.existing")); |
| 345 | // Export the UI content |
| 346 | if(!config.getBoolean("tsd.ui.noexport")) { |
| 347 | loadContent(config.getString("tsd.http.staticroot")); |
| 348 | } |
| 349 | // Create the cache dir if it does not exist |
| 350 | File cacheDir = new File(config.getString("tsd.http.cachedir")); |
| 351 | if(cacheDir.exists()) { |
| 352 | if(!cacheDir.isDirectory()) { |
| 353 | throw new IllegalArgumentException("The http cache directory [" + cacheDir + "] is not a directory, but a file, which is bad"); |
| 354 | } |
| 355 | } else { |
| 356 | if(!cacheDir.mkdirs()) { |
| 357 | throw new IllegalArgumentException("Failed to create the http cache directory [" + cacheDir + "]"); |
| 358 | } |
| 359 | } |
| 360 | } catch (Exception ex) { |
| 361 | log.error("Failed to process tsd configuration", ex); |
| 362 | System.exit(-1); |
| 363 | } |
| 364 | |
| 365 | // ===================================================================== |
| 366 | // Command line processing complete, ready to start TSD. |
| 367 | // The code from here to the end of the method is an exact duplicate |
| 368 | // of {@link TSDMain#main(String[])} once configuration is complete. |
no test coverage detected