mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 13:19:02 +00:00

Since some of the export tasks have been memory hungry, sometimes killing the executor-services, they've been moved to a separate process that can be given a larger Xmx. While doing this, the ProcessMainClass was given utilities for the boilerplate surrounding receiving mq requests and responding to them, some effort was also put toward making the process boot process a bit more uniform. It's still a bit heterogeneous between different processes, but a bit less so for now.
50 lines
1.7 KiB
Java
50 lines
1.7 KiB
Java
package nu.marginalia.livecrawler;
|
|
|
|
import com.google.inject.AbstractModule;
|
|
import com.google.inject.Inject;
|
|
import com.google.inject.Provides;
|
|
import com.google.inject.Singleton;
|
|
import com.google.inject.name.Names;
|
|
import nu.marginalia.IndexLocations;
|
|
import nu.marginalia.UserAgent;
|
|
import nu.marginalia.WmsaHome;
|
|
import nu.marginalia.linkdb.docs.DocumentDbWriter;
|
|
import nu.marginalia.process.ProcessConfiguration;
|
|
import nu.marginalia.service.ServiceId;
|
|
import nu.marginalia.service.module.ServiceConfiguration;
|
|
import nu.marginalia.storage.FileStorageService;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.Files;
|
|
import java.nio.file.Path;
|
|
import java.sql.SQLException;
|
|
import java.util.UUID;
|
|
|
|
import static nu.marginalia.linkdb.LinkdbFileNames.DOCDB_FILE_NAME;
|
|
|
|
public class LiveCrawlerModule extends AbstractModule {
|
|
|
|
public void configure() {
|
|
bind(UserAgent.class).toInstance(WmsaHome.getUserAgent());
|
|
bind(Path.class).annotatedWith(Names.named("local-index-path")).toInstance(Path.of(System.getProperty("local-index-path", "/vol")));
|
|
}
|
|
|
|
@Inject
|
|
@Provides @Singleton
|
|
private DocumentDbWriter createLinkdbWriter(FileStorageService service) throws SQLException, IOException {
|
|
// Migrate
|
|
Path dbPath = IndexLocations.getLinkdbWritePath(service).resolve(DOCDB_FILE_NAME);
|
|
|
|
if (Files.exists(dbPath)) {
|
|
Files.delete(dbPath);
|
|
}
|
|
return new DocumentDbWriter(dbPath);
|
|
}
|
|
|
|
@Singleton
|
|
@Provides
|
|
public ServiceConfiguration provideServiceConfiguration(ProcessConfiguration processConfiguration) {
|
|
return new ServiceConfiguration(ServiceId.NOT_A_SERVICE, processConfiguration.node(), null, null, -1, UUID.randomUUID());
|
|
}
|
|
}
|