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
 | 
			
		||||
# Disable the usage of RYD
 | 
			
		||||
DISABLE_RYD:false
 | 
			
		||||
# Disable API server (node just runs timers if enabled)
 | 
			
		||||
DISABLE_SERVER:false
 | 
			
		||||
# Hibernate properties
 | 
			
		||||
hibernate.connection.url:jdbc:postgresql://postgres:5432/piped
 | 
			
		||||
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.User;
 | 
			
		||||
import me.kavin.piped.utils.obj.db.Video;
 | 
			
		||||
import org.hibernate.Session;
 | 
			
		||||
import org.hibernate.StatelessSession;
 | 
			
		||||
import org.schabi.newpipe.extractor.NewPipe;
 | 
			
		||||
import org.schabi.newpipe.extractor.localization.Localization;
 | 
			
		||||
| 
						 | 
				
			
			@ -40,13 +41,21 @@ public class Main {
 | 
			
		|||
            }
 | 
			
		||||
        }, 0, TimeUnit.MINUTES.toMillis(60));
 | 
			
		||||
 | 
			
		||||
        new Thread(() -> {
 | 
			
		||||
            try {
 | 
			
		||||
                new ServerLauncher().launch(args);
 | 
			
		||||
            } catch (Exception e) {
 | 
			
		||||
                throw new RuntimeException(e);
 | 
			
		||||
            }
 | 
			
		||||
        }).start();
 | 
			
		||||
        if (!Constants.DISABLE_SERVER)
 | 
			
		||||
            new Thread(() -> {
 | 
			
		||||
                try {
 | 
			
		||||
                    new ServerLauncher().launch(args);
 | 
			
		||||
                } catch (Exception e) {
 | 
			
		||||
                    throw new RuntimeException(e);
 | 
			
		||||
                }
 | 
			
		||||
            }).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)
 | 
			
		||||
            return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -55,6 +55,8 @@ public class Constants {
 | 
			
		|||
 | 
			
		||||
    public static final boolean DISABLE_RYD;
 | 
			
		||||
 | 
			
		||||
    public static final boolean DISABLE_SERVER;
 | 
			
		||||
 | 
			
		||||
    public static final String VERSION;
 | 
			
		||||
 | 
			
		||||
    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"));
 | 
			
		||||
            RYD_PROXY_URL = getProperty(prop, "RYD_PROXY_URL", "https://ryd-proxy.kavin.rocks");
 | 
			
		||||
            DISABLE_RYD = Boolean.parseBoolean(getProperty(prop, "DISABLE_RYD", "false"));
 | 
			
		||||
            DISABLE_SERVER = Boolean.parseBoolean(getProperty(prop, "DISABLE_SERVER", "false"));
 | 
			
		||||
            System.getenv().forEach((key, value) -> {
 | 
			
		||||
                if (key.startsWith("hibernate"))
 | 
			
		||||
                    hibernateProperties.put(key, value);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue