(String[] args)
| 73 | private static volatile boolean running = true; |
| 74 | |
| 75 | public static void main(String[] args) { |
| 76 | LOGGER.info("Starting.."); |
| 77 | LOGGER.info("Logging mode set to {}", LogConfigVars.getLogMode(LogConfigVars.LOG_MODE).name()); |
| 78 | LOGGER.info("Thread pool size set to {}", Math.max(4, Runtime.getRuntime().availableProcessors() / 2)); // This math is actually done in FetcharrAPIImpl |
| 79 | |
| 80 | Tristate memoryCache = CacheConfigVars.getTristate(CacheConfigVars.USE_MEMORY_CACHE); |
| 81 | Tristate fileCache = CacheConfigVars.getTristate(CacheConfigVars.USE_FILE_CACHE); |
| 82 | boolean cacheWritable = isCacheWritable(); |
| 83 | |
| 84 | if ((fileCache == Tristate.AUTO && cacheWritable) || fileCache == Tristate.TRUE) { |
| 85 | LOGGER.info("Using disk-based cache"); |
| 86 | } else { |
| 87 | LOGGER.warn("Not using disk-based cache"); |
| 88 | } |
| 89 | if ((memoryCache == Tristate.AUTO && fileCache == Tristate.AUTO && !cacheWritable) || (memoryCache == Tristate.AUTO && fileCache == Tristate.FALSE) || memoryCache == Tristate.TRUE) { |
| 90 | LOGGER.info("Using memory-based cache"); |
| 91 | } else { |
| 92 | LOGGER.info("Not using memory-based cache"); |
| 93 | } |
| 94 | |
| 95 | setupUnirest(); |
| 96 | |
| 97 | LOGGER.info("---"); |
| 98 | |
| 99 | try { |
| 100 | Thread.sleep(3_000); |
| 101 | } catch (InterruptedException ignored) { |
| 102 | Thread.currentThread().interrupt(); |
| 103 | } |
| 104 | |
| 105 | APIRegistrationUtil.register(new FetcharrAPIImpl()); |
| 106 | |
| 107 | // Init after loading all plugins so they can see each other |
| 108 | FetcharrAPIProvider.instance().pluginManager().init(); |
| 109 | FetcharrAPIProvider.instance().pluginManager().start(); |
| 110 | |
| 111 | for (int i = 0; i < 100; i++) { |
| 112 | setupRadarr(i); |
| 113 | setupSonarr(i); |
| 114 | setupLidarr(i); |
| 115 | setupReadarr(i); |
| 116 | setupWhisparr(i); |
| 117 | } |
| 118 | |
| 119 | Runtime.getRuntime().addShutdownHook(new Thread(() -> { |
| 120 | LOGGER.info("Shutting down.."); |
| 121 | |
| 122 | FetcharrAPI api = FetcharrAPIProvider.instance(); |
| 123 | api.pluginManager().shutdown(); |
| 124 | APIRegistrationUtil.deregister(); |
| 125 | api.updateManager().shutdown(10_000L); |
| 126 | |
| 127 | Unirest.shutDown(); |
| 128 | |
| 129 | running = false; |
| 130 | })); |
| 131 | |
| 132 | while (running) { |
nothing calls this directly
no test coverage detected