mirror of
https://github.com/TeamPiped/Piped-Backend.git
synced 2024-08-14 23:51:41 +00:00
Merge pull request #316 from TeamPiped/disable-server
Allow disabling server on a node.
This commit is contained in:
commit
66a9f27746
3 changed files with 21 additions and 7 deletions
|
@ -25,6 +25,8 @@ DISABLE_TIMERS:false
|
||||||
RYD_PROXY_URL:https://ryd-proxy.kavin.rocks
|
RYD_PROXY_URL:https://ryd-proxy.kavin.rocks
|
||||||
# Disable the usage of RYD
|
# Disable the usage of RYD
|
||||||
DISABLE_RYD:false
|
DISABLE_RYD:false
|
||||||
|
# Disable API server (node just runs timers if enabled)
|
||||||
|
DISABLE_SERVER: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
|
||||||
|
|
|
@ -9,6 +9,7 @@ import me.kavin.piped.utils.obj.db.PlaylistVideo;
|
||||||
import me.kavin.piped.utils.obj.db.PubSub;
|
import me.kavin.piped.utils.obj.db.PubSub;
|
||||||
import me.kavin.piped.utils.obj.db.User;
|
import me.kavin.piped.utils.obj.db.User;
|
||||||
import me.kavin.piped.utils.obj.db.Video;
|
import me.kavin.piped.utils.obj.db.Video;
|
||||||
|
import org.hibernate.Session;
|
||||||
import org.hibernate.StatelessSession;
|
import org.hibernate.StatelessSession;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.localization.Localization;
|
import org.schabi.newpipe.extractor.localization.Localization;
|
||||||
|
@ -40,6 +41,7 @@ public class Main {
|
||||||
}
|
}
|
||||||
}, 0, TimeUnit.MINUTES.toMillis(60));
|
}, 0, TimeUnit.MINUTES.toMillis(60));
|
||||||
|
|
||||||
|
if (!Constants.DISABLE_SERVER)
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
new ServerLauncher().launch(args);
|
new ServerLauncher().launch(args);
|
||||||
|
@ -48,6 +50,13 @@ public class Main {
|
||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
|
|
||||||
|
try (Session ignored = DatabaseSessionFactory.createSession()) {
|
||||||
|
System.out.println("Database connection is ready!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
System.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
if (Constants.DISABLE_TIMERS)
|
if (Constants.DISABLE_TIMERS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,8 @@ public class Constants {
|
||||||
|
|
||||||
public static final boolean DISABLE_RYD;
|
public static final boolean DISABLE_RYD;
|
||||||
|
|
||||||
|
public static final boolean DISABLE_SERVER;
|
||||||
|
|
||||||
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);
|
||||||
|
@ -84,6 +86,7 @@ public class Constants {
|
||||||
DISABLE_TIMERS = Boolean.parseBoolean(getProperty(prop, "DISABLE_TIMERS", "false"));
|
DISABLE_TIMERS = Boolean.parseBoolean(getProperty(prop, "DISABLE_TIMERS", "false"));
|
||||||
RYD_PROXY_URL = getProperty(prop, "RYD_PROXY_URL", "https://ryd-proxy.kavin.rocks");
|
RYD_PROXY_URL = getProperty(prop, "RYD_PROXY_URL", "https://ryd-proxy.kavin.rocks");
|
||||||
DISABLE_RYD = Boolean.parseBoolean(getProperty(prop, "DISABLE_RYD", "false"));
|
DISABLE_RYD = Boolean.parseBoolean(getProperty(prop, "DISABLE_RYD", "false"));
|
||||||
|
DISABLE_SERVER = Boolean.parseBoolean(getProperty(prop, "DISABLE_SERVER", "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…
Reference in a new issue