refactor: Move creation of status.json file back to its original place
@@ -159,6 +159,25 @@ public class Application implements ApplicationRunner {
}
}
+ //Create status output file.
+ logger.info("");
+ try {
+ if (detectBootResultOptional.isPresent() && detectBootResultOptional.get().getDirectoryManager().isPresent()) {
+ DirectoryManager directoryManager = detectBootResultOptional.get().getDirectoryManager().get();
+
+ File statusFile = new File(directoryManager.getStatusOutputDirectory(), "status.json");
+ logger.info(String.format("Creating status file: %s", statusFile.toString()));
+
+ String json = gson.toJson(formattedOutputManager.createFormattedOutput(detectInfo));
+ FileUtils.writeStringToFile(statusFile, json, Charset.defaultCharset());
+ } else {
+ logger.info("Will not create status file, detect did not boot.");
+ }
+ } catch (Exception e) {
+ logger.warn("There was a problem writing the status output file. The detect run was not affected.");
+ logger.debug("The problem creating the status file was: ", e);
+ }
+
try {
logger.debug("Detect shutdown begin.");
final ShutdownManager shutdownManager = new ShutdownManager();
@@ -191,25 +210,6 @@ public class Application implements ApplicationRunner {
statusManager.logDetectResults(new Slf4jIntLogger(logger), finalExitCode);
}
- //Create status output file.
- logger.info("");
- try {
- if (detectBootResultOptional.isPresent() && detectBootResultOptional.get().getDirectoryManager().isPresent()) {
- DirectoryManager directoryManager = detectBootResultOptional.get().getDirectoryManager().get();
-
- File statusFile = new File(directoryManager.getStatusOutputDirectory(), "status.json");
- logger.info(String.format("Creating status file: %s", statusFile.toString()));
-
- String json = gson.toJson(formattedOutputManager.createFormattedOutput(detectInfo));
- FileUtils.writeStringToFile(statusFile, json, Charset.defaultCharset());
- } else {
- logger.info("Will not create status file, detect did not boot.");
- }
- } catch (Exception e) {
- logger.warn("There was a problem writing the status output file. The detect run was not affected.");
- logger.debug("The problem creating the status file was: ", e);
- }
-
//Print duration of run
final long endTime = System.currentTimeMillis();
logger.info(String.format("Detect duration: %s", DurationFormatUtils.formatPeriod(startTime, endTime, "HH'h' mm'm' ss's' SSS'ms'")));
