mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Allow disabling pubsub timer to lower cpu usage. (#289)
This commit is contained in:
parent
d4898b8e6c
commit
160e6933d3
3 changed files with 22 additions and 14 deletions
|
@ -19,6 +19,8 @@ COMPROMISED_PASSWORD_CHECK:true
|
|||
DISABLE_REGISTRATION:false
|
||||
# Feed Retention Time in Days
|
||||
FEED_RETENTION:30
|
||||
# Disable CPU expensive timers (for nodes with low CPU, at least one node should have this disabled)
|
||||
DISABLE_TIMERS:false
|
||||
# Hibernate properties
|
||||
hibernate.connection.url:jdbc:postgresql://postgres:5432/piped
|
||||
hibernate.connection.driver_class:org.postgresql.Driver
|
||||
|
|
|
@ -30,6 +30,23 @@ public class Main {
|
|||
|
||||
Injector.useSpecializer();
|
||||
|
||||
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println(String.format("ThrottlingCache: %o entries", YoutubeThrottlingDecrypter.getCacheSize()));
|
||||
YoutubeThrottlingDecrypter.clearCache();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0, TimeUnit.MINUTES.toMillis(60));
|
||||
|
||||
new ServerLauncher().launch(args);
|
||||
|
||||
if (Constants.DISABLE_TIMERS)
|
||||
return;
|
||||
|
||||
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -83,19 +100,5 @@ public class Main {
|
|||
}
|
||||
}, 0, TimeUnit.MINUTES.toMillis(60));
|
||||
|
||||
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
System.out.println(String.format("ThrottlingCache: %o entries", YoutubeThrottlingDecrypter.getCacheSize()));
|
||||
YoutubeThrottlingDecrypter.clearCache();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}, 0, TimeUnit.MINUTES.toMillis(60));
|
||||
|
||||
new ServerLauncher().launch(args);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,6 +47,8 @@ public class Constants {
|
|||
|
||||
public static final int FEED_RETENTION;
|
||||
|
||||
public static final boolean DISABLE_TIMERS;
|
||||
|
||||
public static final String VERSION;
|
||||
|
||||
public static final ObjectMapper mapper = new ObjectMapper().addMixIn(Page.class, PageMixin.class);
|
||||
|
@ -72,6 +74,7 @@ public class Constants {
|
|||
COMPROMISED_PASSWORD_CHECK = Boolean.parseBoolean(getProperty(prop, "COMPROMISED_PASSWORD_CHECK", "true"));
|
||||
DISABLE_REGISTRATION = Boolean.parseBoolean(getProperty(prop, "DISABLE_REGISTRATION", "false"));
|
||||
FEED_RETENTION = Integer.parseInt(getProperty(prop, "FEED_RETENTION", "30"));
|
||||
DISABLE_TIMERS = Boolean.parseBoolean(getProperty(prop, "DISABLE_TIMERS", "false"));
|
||||
System.getenv().forEach((key, value) -> {
|
||||
if (key.startsWith("hibernate"))
|
||||
hibernateProperties.put(key, value);
|
||||
|
|
Loading…
Reference in a new issue