mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2025-04-29 08:20:30 +05:30
Allow disabling pubsub timer to lower cpu usage. (#289)
This commit is contained in:
parent
d4898b8e6c
commit
160e6933d3
@ -19,6 +19,8 @@ COMPROMISED_PASSWORD_CHECK:true
|
|||||||
DISABLE_REGISTRATION:false
|
DISABLE_REGISTRATION:false
|
||||||
# Feed Retention Time in Days
|
# Feed Retention Time in Days
|
||||||
FEED_RETENTION:30
|
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 properties
|
||||||
hibernate.connection.url:jdbc:postgresql://postgres:5432/piped
|
hibernate.connection.url:jdbc:postgresql://postgres:5432/piped
|
||||||
hibernate.connection.driver_class:org.postgresql.Driver
|
hibernate.connection.driver_class:org.postgresql.Driver
|
||||||
|
@ -30,6 +30,23 @@ public class Main {
|
|||||||
|
|
||||||
Injector.useSpecializer();
|
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() {
|
new Timer().scheduleAtFixedRate(new TimerTask() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -83,19 +100,5 @@ public class Main {
|
|||||||
}
|
}
|
||||||
}, 0, TimeUnit.MINUTES.toMillis(60));
|
}, 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 int FEED_RETENTION;
|
||||||
|
|
||||||
|
public static final boolean DISABLE_TIMERS;
|
||||||
|
|
||||||
public static final String VERSION;
|
public static final String VERSION;
|
||||||
|
|
||||||
public static final ObjectMapper mapper = new ObjectMapper().addMixIn(Page.class, PageMixin.class);
|
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"));
|
COMPROMISED_PASSWORD_CHECK = Boolean.parseBoolean(getProperty(prop, "COMPROMISED_PASSWORD_CHECK", "true"));
|
||||||
DISABLE_REGISTRATION = Boolean.parseBoolean(getProperty(prop, "DISABLE_REGISTRATION", "false"));
|
DISABLE_REGISTRATION = Boolean.parseBoolean(getProperty(prop, "DISABLE_REGISTRATION", "false"));
|
||||||
FEED_RETENTION = Integer.parseInt(getProperty(prop, "FEED_RETENTION", "30"));
|
FEED_RETENTION = Integer.parseInt(getProperty(prop, "FEED_RETENTION", "30"));
|
||||||
|
DISABLE_TIMERS = Boolean.parseBoolean(getProperty(prop, "DISABLE_TIMERS", "false"));
|
||||||
System.getenv().forEach((key, value) -> {
|
System.getenv().forEach((key, value) -> {
|
||||||
if (key.startsWith("hibernate"))
|
if (key.startsWith("hibernate"))
|
||||||
hibernateProperties.put(key, value);
|
hibernateProperties.put(key, value);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user