Skip to content

Commit

Permalink
Merge branch 'datavane:dev' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
chenss-1 authored Aug 1, 2024
2 parents 88c6fb3 + 312834d commit a9ecf28
Show file tree
Hide file tree
Showing 30 changed files with 1,133 additions and 422 deletions.
2 changes: 1 addition & 1 deletion bin/datasophon-api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ case $startStop in
fi
echo starting $command, logging to $log

exec_command="$DDH_OPTS -classpath $DDH_CONF_DIR:$DDH_LIB_JARS $CLASS"
exec_command="$DDH_OPTS -Dspring.profiles.active=config -classpath $DDH_CONF_DIR:$DDH_LIB_JARS $CLASS"

echo "nohup $JAVA $exec_command > $log 2>&1 &"
nohup $JAVA $exec_command > $log 2>&1 &
Expand Down
5 changes: 5 additions & 0 deletions datasophon-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
<artifactId>datasophon-ui</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-proxy</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void addInterceptors(InterceptorRegistry registry) {
// login
registry.addInterceptor(loginInterceptor())
.addPathPatterns("/**").excludePathPatterns("/login", "/error",
"/grafana/**",
"/service/install/downloadPackage",
"/service/install/downloadResource",
"/cluster/alert/history/save",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,27 @@ public class ConfigPropertiesExtend implements EnvironmentPostProcessor {
@Override
public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) {
MutablePropertySources propertySources = environment.getPropertySources();

// load the datasophon configuration (config/profiles/application-config.yml)
List<String> activeProfiles = Arrays.asList(environment.getActiveProfiles());
if (!activeProfiles.isEmpty() && !Collections.singletonList("config").containsAll(activeProfiles)) {
// running other profiles
return;
}
try {
List<PropertySource<?>> configPropertySources = new YamlPropertySourceLoader().load(DEFAULT_APPLICATION_CONFIG, new FileSystemResource(DEFAULT_APPLICATION_CONFIG));
if (!CollectionUtils.isEmpty(configPropertySources)) {
for (PropertySource<?> propertySource : configPropertySources) {
propertySources.addFirst(propertySource);
}
}
} catch (Exception e) {
System.err.println("Default config application-config not found ");
log.error("Default config application-config not found", e);
}

// load the datasophon configuration (config/datasophon.conf)
Properties properties = loadCustomProperties();
checkProfile(environment);
propertySources.addFirst(new PropertiesPropertySource("datasophonConfig", properties));
}

Expand All @@ -47,8 +66,7 @@ private Properties loadCustomProperties() {
try (InputStream inputStream = Files.newInputStream(file.toPath())) {
properties.load(inputStream);
} catch (Exception e) {
System.err.println(
"Failed to load the datart configuration (config/datart.conf), use application-config.yml");
System.err.println("Failed to load the datasophon configuration (config/datasophon.conf), use application-config.yml");
return new Properties();
}
List<Object> removeKeys = new ArrayList<>();
Expand All @@ -64,22 +82,4 @@ private Properties loadCustomProperties() {
}
return properties;
}

private void checkProfile(ConfigurableEnvironment environment) {
List<String> activeProfiles = Arrays.asList(environment.getActiveProfiles());
if (!activeProfiles.isEmpty() && !Collections.singletonList("config").containsAll(activeProfiles)) {
// running other profiles
return;
}
try {
List<PropertySource<?>> propertySources = new YamlPropertySourceLoader().load(DEFAULT_APPLICATION_CONFIG,
new FileSystemResource(DEFAULT_APPLICATION_CONFIG));
if (CollectionUtils.isEmpty(propertySources)) {
System.err.println("Default config application-config not found ");
}
} catch (Exception e) {
System.err.println("Default config application-config not found ");
log.error("Default config application-config not found", e);
}
}
}
Loading

0 comments on commit a9ecf28

Please sign in to comment.