Skip to content
Snippets Groups Projects
Verified Commit 3ab39ffc authored by Sebastian's avatar Sebastian
Browse files

Move parameter for not exiting to stopServices()

parent e42dd547
Branches
Tags
1 merge request!121Add parameter that can be used to instruct mailbox not to exit on stop
Pipeline #12093 passed
......@@ -158,7 +158,7 @@ class MailboxService : Service() {
if (started) {
androidExecutor.runOnBackgroundThread {
try {
lifecycleManager.stopServices()
lifecycleManager.stopServices(true)
lifecycleManager.waitForShutdown()
} catch (e: InterruptedException) {
LOG.info("Interrupted while waiting for shutdown")
......
......@@ -121,12 +121,12 @@ class Main : CliktCommand(
private fun startLifecycle() {
Runtime.getRuntime().addShutdownHook(
Thread {
lifecycleManager.stopServices()
lifecycleManager.stopServices(false)
lifecycleManager.waitForShutdown()
}
)
lifecycleManager.startServices(false)
lifecycleManager.startServices()
lifecycleManager.waitForStartup()
if (setupToken != null) {
......
......@@ -74,10 +74,7 @@ interface LifecycleManager {
* registered [Services][Service].
*/
@Wakeful
fun startServices(
exitAfterStopping: Boolean = true,
wipeHook: WipeHook = WipeHook { },
): StartResult
fun startServices(wipeHook: WipeHook = WipeHook { }): StartResult
/**
* Stops any registered [Services][Service], shuts down any
......@@ -85,7 +82,7 @@ interface LifecycleManager {
* [Database].
*/
@Wakeful
fun stopServices()
fun stopServices(exitAfterStopping: Boolean)
/**
* Wipes entire database as well as stored files. Also stops all services
......
......@@ -82,7 +82,6 @@ internal class LifecycleManagerImpl @Inject constructor(
private val state = MutableStateFlow(NOT_STARTED)
private var wipeHook: WipeHook? = null
private var exitAfterStopping: Boolean = true
init {
services = CopyOnWriteArrayList()
......@@ -106,7 +105,7 @@ internal class LifecycleManagerImpl @Inject constructor(
}
@GuardedBy("startStopWipeSemaphore")
override fun startServices(exitAfterStopping: Boolean, wipeHook: WipeHook): StartResult {
override fun startServices(wipeHook: WipeHook): StartResult {
LOG.info("startServices()")
try {
LOG.info("acquiring start stop semaphore")
......@@ -122,7 +121,6 @@ internal class LifecycleManagerImpl @Inject constructor(
return LIFECYCLE_REUSE
}
this.wipeHook = wipeHook
this.exitAfterStopping = exitAfterStopping
return try {
LOG.info("Opening database")
var start = now()
......@@ -169,7 +167,7 @@ internal class LifecycleManagerImpl @Inject constructor(
}
@GuardedBy("startStopWipeSemaphore")
override fun stopServices() {
override fun stopServices(exitAfterStopping: Boolean) {
LOG.info("stopServices()")
try {
LOG.info("acquiring start stop semaphore")
......@@ -265,7 +263,7 @@ internal class LifecycleManagerImpl @Inject constructor(
// If we were not do this, the webserver would wait for the request to finish and the
// request would wait for the webserver to finish.
thread {
stopServices()
stopServices(true)
}
return true
} finally {
......
......@@ -87,7 +87,7 @@ abstract class IntegrationTest(private val installJsonFeature: Boolean = true) {
@AfterAll
fun tearDown() {
lifecycleManager.stopServices()
lifecycleManager.stopServices(false)
lifecycleManager.waitForShutdown()
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment