Skip to content

Commit

Permalink
[cuebot] Automatically replace --log.frame-log-root with the new flag. (
Browse files Browse the repository at this point in the history
  • Loading branch information
bcipriano committed Dec 6, 2022
1 parent c8eb6ca commit 35aa461
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions cuebot/src/main/java/com/imageworks/spcue/CuebotApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,48 @@
*/



package com.imageworks.spcue;

import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Stream;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class CuebotApplication extends SpringApplication {
private static String[] checkArgs(String[] args) {
Optional<String> deprecatedFlag = Arrays.stream(args)
.filter(arg -> arg.startsWith("--log.frame-log-root=")).findFirst();
if (deprecatedFlag.isPresent()) {
// Log a deprecation warning.
Logger warning_logger = Logger.getLogger(CuebotApplication.class);
warning_logger.warn("`--log.frame-log-root` is deprecated and will be removed in an " +
"upcoming release. It has been replaced with `--log.frame-log-root.default_os`. " +
"See opencue.properties for details on OpenCue's new OS-dependent root directories.");
// If new flags are not present, swap in the value provided using the new flag.
// If the new flags are already present, don't do anything.
Optional<String> newFlags = Arrays.stream(args)
.filter(arg -> arg.startsWith("--log.frame-log-root.")).findAny();
if (!newFlags.isPresent()) {
String fixedFlag = "--log.frame-log-root.default_os="
+ StringUtils.substringAfter(deprecatedFlag.get(), "=");
args = Stream.concat(
Arrays.stream(args).filter(arg -> !arg.startsWith("--log.frame-log-root=")),
Stream.of(fixedFlag))
.toArray(String[]::new);
}
}
return args;
}

public static void main(String[] args) {
// Cuebot startup
SpringApplication.run(CuebotApplication.class, args);
String[] filteredArgs = checkArgs(args);
SpringApplication.run(CuebotApplication.class, filteredArgs);
}
}

0 comments on commit 35aa461

Please sign in to comment.