Skip to content

Commit

Permalink
Stop hanging for 10 seconds on shutdown
Browse files Browse the repository at this point in the history
The file notification service was missing its shutdown call.
  • Loading branch information
zapek committed Apr 14, 2024
1 parent 8d22e96 commit 657fa1b
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions app/src/main/java/io/xeres/app/application/Startup.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import io.xeres.app.service.SettingsService;
import io.xeres.app.service.ShellService;
import io.xeres.app.service.file.FileService;
import io.xeres.app.service.notification.file.FileNotificationService;
import io.xeres.app.service.notification.status.StatusNotificationService;
import io.xeres.app.xrs.service.RsServiceRegistry;
import io.xeres.app.xrs.service.identity.IdentityManager;
Expand Down Expand Up @@ -82,8 +83,9 @@ public class Startup implements ApplicationRunner
private final RsServiceRegistry rsServiceRegistry;
private final FileService fileService;
private final ShellService shellService;
private final FileNotificationService fileNotificationService;

public Startup(LocationService locationService, SettingsService settingsService, BuildProperties buildProperties, Environment environment, NetworkProperties networkProperties, DatabaseSessionManager databaseSessionManager, DataDirConfiguration dataDirConfiguration, NetworkService networkService, PeerConnectionManager peerConnectionManager, SplashService splashService, IdentityManager identityManager, StatusNotificationService statusNotificationService, AutoStart autoStart, RsServiceRegistry rsServiceRegistry, FileService fileService, ShellService shellService)
public Startup(LocationService locationService, SettingsService settingsService, BuildProperties buildProperties, Environment environment, NetworkProperties networkProperties, DatabaseSessionManager databaseSessionManager, DataDirConfiguration dataDirConfiguration, NetworkService networkService, PeerConnectionManager peerConnectionManager, SplashService splashService, IdentityManager identityManager, StatusNotificationService statusNotificationService, AutoStart autoStart, RsServiceRegistry rsServiceRegistry, FileService fileService, ShellService shellService, FileNotificationService fileNotificationService)
{
this.locationService = locationService;
this.settingsService = settingsService;
Expand All @@ -101,6 +103,7 @@ public Startup(LocationService locationService, SettingsService settingsService,
this.rsServiceRegistry = rsServiceRegistry;
this.fileService = fileService;
this.shellService = shellService;
this.fileNotificationService = fileNotificationService;
}

@Override
Expand Down Expand Up @@ -139,10 +142,10 @@ public void run(ApplicationArguments args)
/**
* Called when the application setup is ready (aka we have a location).
*
* @param event the LocationReadyEvent
* @param ignoredEvent the LocationReadyEvent
*/
@EventListener
public void onApplicationEvent(LocationReadyEvent event)
public void onApplicationEvent(LocationReadyEvent ignoredEvent)
{
try (var ignored = new DatabaseSession(databaseSessionManager))
{
Expand All @@ -161,7 +164,7 @@ public void onSettingsChangedEvent(SettingsChangedEvent event)
}

@EventListener // We don't use @PreDestroy because netty uses other beans on shutdown, and we don't want them in shutdown state already
public void onApplicationEvent(ContextClosedEvent event)
public void onApplicationEvent(ContextClosedEvent ignored)
{
backupUserData();

Expand All @@ -170,6 +173,7 @@ public void onApplicationEvent(ContextClosedEvent event)
peerConnectionManager.shutdown();

statusNotificationService.shutdown();
fileNotificationService.shutdown();

networkService.stop();
}
Expand Down

0 comments on commit 657fa1b

Please sign in to comment.