mirror of
				https://github.com/Frooodle/Stirling-PDF.git
				synced 2025-10-25 11:17:28 +02:00 
			
		
		
		
	logs and cleanup
This commit is contained in:
		
							parent
							
								
									13572a7f18
								
							
						
					
					
						commit
						509a305985
					
				| @ -33,9 +33,6 @@ version = "0.36.1" | |||||||
| java { | java { | ||||||
|     // 17 is lowest but we support and recommend 21 |     // 17 is lowest but we support and recommend 21 | ||||||
|     sourceCompatibility = JavaVersion.VERSION_17 |     sourceCompatibility = JavaVersion.VERSION_17 | ||||||
|      toolchain { |  | ||||||
|         languageVersion = JavaLanguageVersion.of(17) |  | ||||||
|     } |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| repositories { | repositories { | ||||||
| @ -88,9 +85,9 @@ openApi { | |||||||
|     outputFileName = "SwaggerDoc.json" |     outputFileName = "SwaggerDoc.json" | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | //0.11.5 to 2024.11.5 | ||||||
| def getMacVersion(String version) { | def getMacVersion(String version) { | ||||||
|     def currentYear = java.time.Year.now().getValue() |     def currentYear = java.time.Year.now().getValue() | ||||||
|     // Extract everything after the first dot (or the whole string if no dot) |  | ||||||
|     def versionParts = version.split("\\.", 2) |     def versionParts = version.split("\\.", 2) | ||||||
|     return "${currentYear}.${versionParts.length > 1 ? versionParts[1] : versionParts[0]}" |     return "${currentYear}.${versionParts.length > 1 ? versionParts[1] : versionParts[0]}" | ||||||
| } | } | ||||||
|  | |||||||
| @ -22,6 +22,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; | |||||||
| import org.springframework.core.env.Environment; | import org.springframework.core.env.Environment; | ||||||
| import org.springframework.scheduling.annotation.EnableScheduling; | import org.springframework.scheduling.annotation.EnableScheduling; | ||||||
| 
 | 
 | ||||||
|  | import io.github.pixee.security.SystemCommand; | ||||||
| import jakarta.annotation.PostConstruct; | import jakarta.annotation.PostConstruct; | ||||||
| import jakarta.annotation.PreDestroy; | import jakarta.annotation.PreDestroy; | ||||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||||
| @ -147,16 +148,32 @@ public class SPdfApplication { | |||||||
| 
 | 
 | ||||||
|     @PostConstruct |     @PostConstruct | ||||||
|     public void init() { |     public void init() { | ||||||
|         log.info( |  | ||||||
|                 "1 STIRLING_PDF_DESKTOP_UI={}", |  | ||||||
|                 Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))); |  | ||||||
|         baseUrlStatic = this.baseUrl; |         baseUrlStatic = this.baseUrl; | ||||||
|         String url = baseUrl + ":" + getStaticPort(); |         String url = baseUrl + ":" + getStaticPort(); | ||||||
|         if (webBrowser != null |         if (webBrowser != null | ||||||
|                 && Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) { |                 && Boolean.parseBoolean(System.getProperty("STIRLING_PDF_DESKTOP_UI", "false"))) { | ||||||
| 
 |  | ||||||
|             webBrowser.initWebUI(url); |             webBrowser.initWebUI(url); | ||||||
|  |         } else { | ||||||
|  |         	String browserOpenEnv = env.getProperty("BROWSER_OPEN"); | ||||||
|  |             boolean browserOpen = browserOpenEnv != null && "true".equalsIgnoreCase(browserOpenEnv); | ||||||
|  |             if (browserOpen) { | ||||||
|  |                 try { | ||||||
|  |                     String os = System.getProperty("os.name").toLowerCase(); | ||||||
|  |                     Runtime rt = Runtime.getRuntime(); | ||||||
|  |                     if (os.contains("win")) { | ||||||
|  |                         // For Windows | ||||||
|  |                         SystemCommand.runCommand(rt, "rundll32 url.dll,FileProtocolHandler " + url); | ||||||
|  |                     } else if (os.contains("mac")) { | ||||||
|  |                         SystemCommand.runCommand(rt, "open " + url); | ||||||
|  |                     } else if (os.contains("nix") || os.contains("nux")) { | ||||||
|  |                         SystemCommand.runCommand(rt, "xdg-open " + url); | ||||||
|                     } |                     } | ||||||
|  |                 } catch (Exception e) { | ||||||
|  |                     logger.error("Error opening browser: {}", e.getMessage()); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         logger.info("Running configs {}", applicationProperties.toString());  | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     @PreDestroy |     @PreDestroy | ||||||
|  | |||||||
| @ -58,12 +58,10 @@ public class DesktopBrowser implements WebBrowser { | |||||||
|     private static SystemTray systemTray; |     private static SystemTray systemTray; | ||||||
| 
 | 
 | ||||||
|     public DesktopBrowser() { |     public DesktopBrowser() { | ||||||
|         log.info("DesktopBrowser 1"); |  | ||||||
|         SwingUtilities.invokeLater( |         SwingUtilities.invokeLater( | ||||||
|                 () -> { |                 () -> { | ||||||
|                     loadingWindow = new LoadingWindow(null, "Initializing..."); |                     loadingWindow = new LoadingWindow(null, "Initializing..."); | ||||||
|                     loadingWindow.setVisible(true); |                     loadingWindow.setVisible(true); | ||||||
|                     log.info("DesktopBrowser 2"); |  | ||||||
|                 }); |                 }); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
| @ -71,10 +69,8 @@ public class DesktopBrowser implements WebBrowser { | |||||||
|         CompletableFuture.runAsync( |         CompletableFuture.runAsync( | ||||||
|                 () -> { |                 () -> { | ||||||
|                     try { |                     try { | ||||||
|                         log.info("DesktopBrowser 4"); |  | ||||||
|                         CefAppBuilder builder = new CefAppBuilder(); |                         CefAppBuilder builder = new CefAppBuilder(); | ||||||
|                         configureCefSettings(builder); |                         configureCefSettings(builder); | ||||||
| 
 |  | ||||||
|                         builder.setProgressHandler(createProgressHandler()); |                         builder.setProgressHandler(createProgressHandler()); | ||||||
| 
 | 
 | ||||||
|                         // Build and initialize CEF |                         // Build and initialize CEF | ||||||
| @ -94,7 +90,6 @@ public class DesktopBrowser implements WebBrowser { | |||||||
|                                     // Show the frame immediately but transparent |                                     // Show the frame immediately but transparent | ||||||
|                                     frame.setVisible(true); |                                     frame.setVisible(true); | ||||||
|                                 }); |                                 }); | ||||||
|                         log.info("DesktopBrowser 5"); |  | ||||||
|                     } catch (Exception e) { |                     } catch (Exception e) { | ||||||
|                         log.error("Error initializing JCEF browser: ", e); |                         log.error("Error initializing JCEF browser: ", e); | ||||||
|                         cleanup(); |                         cleanup(); | ||||||
| @ -156,7 +151,6 @@ public class DesktopBrowser implements WebBrowser { | |||||||
|                 Objects.requireNonNull(state, "state cannot be null"); |                 Objects.requireNonNull(state, "state cannot be null"); | ||||||
|                 SwingUtilities.invokeLater( |                 SwingUtilities.invokeLater( | ||||||
|                         () -> { |                         () -> { | ||||||
|                             log.info("state {}", state.name()); |  | ||||||
|                             if (loadingWindow != null) { |                             if (loadingWindow != null) { | ||||||
|                                 switch (state) { |                                 switch (state) { | ||||||
|                                     case LOCATING: |                                     case LOCATING: | ||||||
| @ -226,7 +220,6 @@ public class DesktopBrowser implements WebBrowser { | |||||||
|                             boolean isLoading, |                             boolean isLoading, | ||||||
|                             boolean canGoBack, |                             boolean canGoBack, | ||||||
|                             boolean canGoForward) { |                             boolean canGoForward) { | ||||||
|                         log.info("Loading state changed: " + isLoading); |  | ||||||
|                         if (!isLoading && !browserInitialized) { |                         if (!isLoading && !browserInitialized) { | ||||||
|                             browserInitialized = true; |                             browserInitialized = true; | ||||||
|                             SwingUtilities.invokeLater( |                             SwingUtilities.invokeLater( | ||||||
| @ -343,7 +336,6 @@ public class DesktopBrowser implements WebBrowser { | |||||||
|             if (icon != null) { |             if (icon != null) { | ||||||
|                 frame.setIconImage(icon); |                 frame.setIconImage(icon); | ||||||
|                 setupTrayIcon(icon); |                 setupTrayIcon(icon); | ||||||
|                 log.info("Successfully set frame icon"); |  | ||||||
|             } else { |             } else { | ||||||
|                 log.warn("Could not load icon from any source"); |                 log.warn("Could not load icon from any source"); | ||||||
|             } |             } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user