mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 13:19:02 +00:00

Since some of the export tasks have been memory hungry, sometimes killing the executor-services, they've been moved to a separate process that can be given a larger Xmx. While doing this, the ProcessMainClass was given utilities for the boilerplate surrounding receiving mq requests and responding to them, some effort was also put toward making the process boot process a bit more uniform. It's still a bit heterogeneous between different processes, but a bit less so for now.
37 lines
1.1 KiB
Java
37 lines
1.1 KiB
Java
package nu.marginalia.service;
|
|
|
|
import nu.marginalia.WmsaHome;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.util.Properties;
|
|
|
|
public class ConfigLoader {
|
|
|
|
public static Path getConfigPath(String configName) {
|
|
return WmsaHome.getHomePath().resolve("conf/properties/" + configName + ".properties");
|
|
}
|
|
|
|
public static void loadConfig(Path configPath) {
|
|
if (!Files.exists(configPath)) {
|
|
System.err.println("No config file found at " + configPath);
|
|
return;
|
|
}
|
|
|
|
System.out.println("Loading config from " + configPath);
|
|
|
|
try (var is = Files.newInputStream(configPath)) {
|
|
var toLoad = new Properties();
|
|
toLoad.load(is);
|
|
for (var key : toLoad.keySet()) {
|
|
String k = (String) key;
|
|
System.out.println("Loading property " + k + " = " + toLoad.getProperty(k));
|
|
System.setProperty(k, toLoad.getProperty(k));
|
|
}
|
|
} catch (IOException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
}
|