mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
shutdown pool when application stops
This commit is contained in:
@@ -27,6 +27,7 @@ import com.commafeed.backend.dao.FeedCategoryDAO;
|
|||||||
import com.commafeed.backend.dao.FeedDAO;
|
import com.commafeed.backend.dao.FeedDAO;
|
||||||
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
import com.commafeed.backend.dao.FeedSubscriptionDAO;
|
||||||
import com.commafeed.backend.dao.UserDAO;
|
import com.commafeed.backend.dao.UserDAO;
|
||||||
|
import com.commafeed.backend.feeds.FeedRefreshUpdater;
|
||||||
import com.commafeed.backend.feeds.FeedRefreshWorker;
|
import com.commafeed.backend.feeds.FeedRefreshWorker;
|
||||||
import com.commafeed.backend.model.ApplicationSettings;
|
import com.commafeed.backend.model.ApplicationSettings;
|
||||||
import com.commafeed.backend.model.UserRole.Role;
|
import com.commafeed.backend.model.UserRole.Role;
|
||||||
@@ -61,6 +62,9 @@ public class StartupBean {
|
|||||||
@Inject
|
@Inject
|
||||||
ApplicationSettingsService applicationSettingsService;
|
ApplicationSettingsService applicationSettingsService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
FeedRefreshUpdater feedRefreshUpdater;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
Instance<FeedRefreshWorker> workers;
|
Instance<FeedRefreshWorker> workers;
|
||||||
|
|
||||||
@@ -145,6 +149,7 @@ public class StartupBean {
|
|||||||
log.error("interrupted while waiting for threads to finish.");
|
log.error("interrupted while waiting for threads to finish.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
feedRefreshUpdater.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,17 @@ public class FeedRefreshUpdater {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void shutdown() {
|
||||||
|
pool.shutdownNow();
|
||||||
|
while (!pool.isTerminated()) {
|
||||||
|
try {
|
||||||
|
Thread.sleep(100);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
log.error("interrupted while waiting for threads to finish.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void updateFeed(Feed feed, Collection<FeedEntry> entries) {
|
public void updateFeed(Feed feed, Collection<FeedEntry> entries) {
|
||||||
pool.execute(new Task(feed, entries));
|
pool.execute(new Task(feed, entries));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user