File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
internal/core/plugin_manager Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package plugin_manager
3
3
import (
4
4
"time"
5
5
6
+ "github.com/langgenius/dify-plugin-daemon/internal/utils/log"
6
7
"github.com/langgenius/dify-plugin-daemon/internal/utils/routine"
7
8
"github.com/langgenius/dify-plugin-daemon/internal/utils/stream"
8
9
"github.com/langgenius/dify-plugin-daemon/pkg/entities/plugin_entities"
@@ -61,7 +62,14 @@ func (p *PluginManager) InstallToLocal(
61
62
return
62
63
case err := <- errChan :
63
64
if err != nil {
64
- // if error occurs, stop the plugin
65
+ // if error occurs, delete the plugin from local and stop the plugin
66
+ identity , err := runtime .Identity ()
67
+ if err != nil {
68
+ log .Error ("get plugin identity failed: %s" , err .Error ())
69
+ }
70
+ if err := p .installedBucket .Delete (identity ); err != nil {
71
+ log .Error ("delete plugin from local failed: %s" , err .Error ())
72
+ }
65
73
response .Write (PluginInstallResponse {
66
74
Event : PluginInstallEventError ,
67
75
Data : err .Error (),
Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ func (p *PluginManager) AddPluginRegisterHandler(handler func(r plugin_entities.
13
13
p .pluginRegisters = append (p .pluginRegisters , handler )
14
14
}
15
15
16
+ // fullDuplexLifecycle takes the responsibility of full-duplex lifecycle of a plugin
17
+ // it will block the thread until the plugin is stopped so it's important to call it in a new goroutine
18
+ // 1. try to init environment until succeed or plugin has failed too many times
19
+ // 2. launchedChan and errChan are used to synchronize the plugin launch process
20
+ // only if received non-nil message from errChan, it's considered the setup process has failed
21
+ // 3. after exit, environment will be cleaned up
22
+ //
23
+ // NOTE: the size of launchedChan and errChan should always be 0 to keep the sync mechanism working
16
24
func (p * PluginManager ) fullDuplexLifecycle (
17
25
r plugin_entities.PluginFullDuplexLifetime ,
18
26
launchedChan chan bool ,
@@ -65,6 +73,8 @@ func (p *PluginManager) fullDuplexLifecycle(
65
73
close (launchedChan )
66
74
}
67
75
})
76
+
77
+ return
68
78
}
69
79
70
80
log .Info ("init environment for plugin %s" , configuration .Identity ())
You can’t perform that action at this time.
0 commit comments