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

Commit 5e49491

Browse files
committed
Only start plugins if all dependencies are ready
1 parent baa1e53 commit 5e49491

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/main/scala/org/codeoverflow/chatoverflow/instance/PluginInstance.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ class PluginInstance(val instanceName: String, pluginType: PluginType) extends W
9999

100100
} else {
101101

102+
if (!areDependenciesAvailable) {
103+
logger error "Dependencies have either failed to resolve and fetch or aren't done yet."
104+
return false
105+
}
106+
102107
// This is set to false if any connector (aka input/output) is not ready.
103108
var allConnectorsReady = true
104109

@@ -224,6 +229,16 @@ class PluginInstance(val instanceName: String, pluginType: PluginType) extends W
224229
}
225230
}
226231

232+
/**
233+
* Returns whether all dependencies are resolved and fetch which is required for the plugin to start.
234+
*
235+
* @return true if all dependencies are available, true if not done of failed.
236+
*/
237+
def areDependenciesAvailable: Boolean = {
238+
val opt = pluginType.getDependencyFuture.value
239+
opt.isDefined && opt.get.isSuccess
240+
}
241+
227242
/**
228243
* Returns if the plugin is currently executed (the thread is running)
229244
*

src/main/scala/org/codeoverflow/chatoverflow/ui/web/rest/plugin/PluginInstanceController.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ class PluginInstanceController(implicit val swagger: Swagger) extends JsonServle
4646
} else if (!pluginInstance.get.getRequirements.getAccess.isComplete) {
4747
ResultMessage(success = false, "Not all required requirements have been set.")
4848

49+
} else if (!pluginInstance.get.areDependenciesAvailable) {
50+
ResultMessage(success = false, "Dependencies have either failed to resolve and fetch or aren't done yet. Check logs for further information.")
51+
4952
} else if (!pluginInstance.get.start()) {
5053
ResultMessage(success = false, "Unable to start plugin.")
5154

0 commit comments

Comments
 (0)