mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-12-13 22:00:29 +05:30
Read properties from environment if available.
Closes https://github.com/TeamPiped/Piped/issues/638
This commit is contained in:
parent
6ec517e0ef
commit
749cf48f4b
@ -55,16 +55,17 @@ public class Constants {
|
||||
YOUTUBE_SERVICE = NewPipe.getService(0);
|
||||
prop.load(new FileReader("config.properties"));
|
||||
|
||||
PORT = Integer.parseInt(prop.getProperty("PORT", "8080"));
|
||||
HTTP_WORKERS = prop.getProperty("HTTP_WORKERS", String.valueOf(Runtime.getRuntime().availableProcessors()));
|
||||
PROXY_PART = prop.getProperty("PROXY_PART");
|
||||
CAPTCHA_BASE_URL = prop.getProperty("CAPTCHA_BASE_URL");
|
||||
CAPTCHA_API_KEY = prop.getProperty("CAPTCHA_API_KEY");
|
||||
PUBLIC_URL = prop.getProperty("API_URL");
|
||||
HTTP_PROXY = prop.getProperty("HTTP_PROXY");
|
||||
FRONTEND_URL = prop.getProperty("FRONTEND_URL", "https://pipedapi.kavin.rocks");
|
||||
COMPROMISED_PASSWORD_CHECK = Boolean.parseBoolean(prop.getProperty("COMPROMISED_PASSWORD_CHECK", "true"));
|
||||
DISABLE_REGISTRATION = Boolean.parseBoolean(prop.getProperty("DISABLE_REGISTRATION", "false"));
|
||||
PORT = Integer.parseInt(getProperty(prop, "PORT", "8080"));
|
||||
HTTP_WORKERS = getProperty(prop, "HTTP_WORKERS",
|
||||
String.valueOf(Runtime.getRuntime().availableProcessors()));
|
||||
PROXY_PART = getProperty(prop, "PROXY_PART");
|
||||
CAPTCHA_BASE_URL = getProperty(prop, "CAPTCHA_BASE_URL");
|
||||
CAPTCHA_API_KEY = getProperty(prop, "CAPTCHA_API_KEY");
|
||||
PUBLIC_URL = getProperty(prop, "API_URL");
|
||||
HTTP_PROXY = getProperty(prop, "HTTP_PROXY");
|
||||
FRONTEND_URL = getProperty(prop, "FRONTEND_URL", "https://pipedapi.kavin.rocks");
|
||||
COMPROMISED_PASSWORD_CHECK = Boolean.parseBoolean(getProperty(prop, "COMPROMISED_PASSWORD_CHECK", "true"));
|
||||
DISABLE_REGISTRATION = Boolean.parseBoolean(getProperty(prop, "DISABLE_REGISTRATION", "false"));
|
||||
prop.forEach((_key, _value) -> {
|
||||
String key = String.valueOf(_key), value = String.valueOf(_value);
|
||||
if (key.startsWith("hibernate"))
|
||||
@ -85,4 +86,18 @@ public class Constants {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private static final String getProperty(final Properties prop, String key) {
|
||||
return getProperty(prop, key, null);
|
||||
}
|
||||
|
||||
private static final String getProperty(final Properties prop, String key, String def) {
|
||||
|
||||
final String envVal = System.getenv(key);
|
||||
|
||||
if (envVal != null)
|
||||
return envVal;
|
||||
|
||||
return prop.getProperty(key, def);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user