mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Read properties from environment if available.
Closes https://github.com/TeamPiped/Piped/issues/638
This commit is contained in:
parent
6ec517e0ef
commit
749cf48f4b
1 changed files with 25 additions and 10 deletions
|
@ -55,16 +55,17 @@ public class Constants {
|
||||||
YOUTUBE_SERVICE = NewPipe.getService(0);
|
YOUTUBE_SERVICE = NewPipe.getService(0);
|
||||||
prop.load(new FileReader("config.properties"));
|
prop.load(new FileReader("config.properties"));
|
||||||
|
|
||||||
PORT = Integer.parseInt(prop.getProperty("PORT", "8080"));
|
PORT = Integer.parseInt(getProperty(prop, "PORT", "8080"));
|
||||||
HTTP_WORKERS = prop.getProperty("HTTP_WORKERS", String.valueOf(Runtime.getRuntime().availableProcessors()));
|
HTTP_WORKERS = getProperty(prop, "HTTP_WORKERS",
|
||||||
PROXY_PART = prop.getProperty("PROXY_PART");
|
String.valueOf(Runtime.getRuntime().availableProcessors()));
|
||||||
CAPTCHA_BASE_URL = prop.getProperty("CAPTCHA_BASE_URL");
|
PROXY_PART = getProperty(prop, "PROXY_PART");
|
||||||
CAPTCHA_API_KEY = prop.getProperty("CAPTCHA_API_KEY");
|
CAPTCHA_BASE_URL = getProperty(prop, "CAPTCHA_BASE_URL");
|
||||||
PUBLIC_URL = prop.getProperty("API_URL");
|
CAPTCHA_API_KEY = getProperty(prop, "CAPTCHA_API_KEY");
|
||||||
HTTP_PROXY = prop.getProperty("HTTP_PROXY");
|
PUBLIC_URL = getProperty(prop, "API_URL");
|
||||||
FRONTEND_URL = prop.getProperty("FRONTEND_URL", "https://pipedapi.kavin.rocks");
|
HTTP_PROXY = getProperty(prop, "HTTP_PROXY");
|
||||||
COMPROMISED_PASSWORD_CHECK = Boolean.parseBoolean(prop.getProperty("COMPROMISED_PASSWORD_CHECK", "true"));
|
FRONTEND_URL = getProperty(prop, "FRONTEND_URL", "https://pipedapi.kavin.rocks");
|
||||||
DISABLE_REGISTRATION = Boolean.parseBoolean(prop.getProperty("DISABLE_REGISTRATION", "false"));
|
COMPROMISED_PASSWORD_CHECK = Boolean.parseBoolean(getProperty(prop, "COMPROMISED_PASSWORD_CHECK", "true"));
|
||||||
|
DISABLE_REGISTRATION = Boolean.parseBoolean(getProperty(prop, "DISABLE_REGISTRATION", "false"));
|
||||||
prop.forEach((_key, _value) -> {
|
prop.forEach((_key, _value) -> {
|
||||||
String key = String.valueOf(_key), value = String.valueOf(_value);
|
String key = String.valueOf(_key), value = String.valueOf(_value);
|
||||||
if (key.startsWith("hibernate"))
|
if (key.startsWith("hibernate"))
|
||||||
|
@ -85,4 +86,18 @@ public class Constants {
|
||||||
throw new RuntimeException(e);
|
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 a new issue