Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 94784c5

Browse files
committed
Stop everything on SIGINT to cleanly shutdown on CTRL+C
1 parent 56ead0c commit 94784c5

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/scala/org/codeoverflow/chatoverflow/Launcher.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ object Launcher extends WithLogger {
7878
logger warn "Unable to run startup plugins. No/wrong password supplied."
7979
}
8080
}
81+
82+
Runtime.getRuntime.addShutdownHook(new Thread(() => exit()))
8183
}
8284
}
8385

@@ -120,6 +122,5 @@ object Launcher extends WithLogger {
120122
}
121123

122124
logger info "Bye Bye. Stay minzig!"
123-
System.exit(0)
124125
}
125126
}

src/main/scala/org/codeoverflow/chatoverflow/ui/web/rest/config/ConfigController.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class ConfigController(implicit val swagger: Swagger) extends JsonServlet with C
3838
// Give enough time to return success. Then bye bye
3939
new Thread(() => {
4040
Thread.sleep(500)
41-
Launcher.exit()
41+
System.exit(0) // Shutdown hook takes care to stop everything (registered on startup by the Launcher)
4242
}).start()
4343
ResultMessage(success = true)
4444
}

0 commit comments

Comments
 (0)