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

This corrects an annoying bug that had the system crash and burn on first start-up due to a race condition in service initialization, where the services were attempting to access the database before it was properly migrated. A fix was in principle already in place, but it was running too late and did not prevent attempts to access the as-yet uninitialized database. Move the first boot check into the MainClass instead of the Service constructor. The change also adds more appropriate docker dependencies to the services to fix rare errors resolving the hostname of the database.
45 lines
1.5 KiB
Java
45 lines
1.5 KiB
Java
package nu.marginalia.dating;
|
|
|
|
import com.google.inject.Guice;
|
|
import com.google.inject.Inject;
|
|
import com.google.inject.Injector;
|
|
import nu.marginalia.service.MainClass;
|
|
import nu.marginalia.service.discovery.ServiceRegistryIf;
|
|
import nu.marginalia.service.module.ServiceConfiguration;
|
|
import nu.marginalia.service.module.ServiceDiscoveryModule;
|
|
import nu.marginalia.service.ServiceId;
|
|
import nu.marginalia.service.module.ServiceConfigurationModule;
|
|
import nu.marginalia.service.module.DatabaseModule;
|
|
import nu.marginalia.service.server.Initialization;
|
|
import spark.Spark;
|
|
|
|
public class DatingMain extends MainClass {
|
|
final DatingService service;
|
|
|
|
@Inject
|
|
public DatingMain(DatingService service) {
|
|
this.service = service;
|
|
}
|
|
|
|
public static void main(String... args) {
|
|
init(ServiceId.Dating, args);
|
|
|
|
Spark.staticFileLocation("/static/dating/");
|
|
|
|
Injector injector = Guice.createInjector(
|
|
new DatingModule(),
|
|
new ServiceDiscoveryModule(),
|
|
new ServiceConfigurationModule(ServiceId.Dating),
|
|
new DatabaseModule(false)
|
|
);
|
|
|
|
// Orchestrate the boot order for the services
|
|
var registry = injector.getInstance(ServiceRegistryIf.class);
|
|
var configuration = injector.getInstance(ServiceConfiguration.class);
|
|
orchestrateBoot(registry, configuration);
|
|
|
|
injector.getInstance(DatingMain.class);
|
|
injector.getInstance(Initialization.class).setReady();
|
|
}
|
|
}
|