Browse Source

duplex installation

Yeuoly 10 months ago
parent
commit
b23b52de82

+ 1 - 1
internal/core/plugin_manager/lifetime.go

@@ -7,7 +7,7 @@ import (
 	"github.com/langgenius/dify-plugin-daemon/internal/utils/log"
 )
 
-func (p *PluginManager) localLifetime(r plugin_entities.PluginFullDuplexLifetime) {
+func (p *PluginManager) fullDuplexLifetime(r plugin_entities.PluginFullDuplexLifetime) {
 	configuration := r.Configuration()
 
 	log.Info("new plugin logged in: %s", configuration.Identity())

+ 2 - 2
internal/core/plugin_manager/watcher.go

@@ -43,7 +43,7 @@ func (p *PluginManager) startRemoteWatcher(config *app.Config) {
 		}()
 		go func() {
 			server.Wrap(func(rpr *remote_manager.RemotePluginRuntime) {
-				p.localLifetime(rpr)
+				p.fullDuplexLifetime(rpr)
 			})
 		}()
 	}
@@ -94,7 +94,7 @@ func (p *PluginManager) handleNewLocalPlugins(config *app.Config) {
 			}()
 			// delete the plugin from the storage when the plugin is stopped
 			defer p.runningPluginInStorage.Delete(plugin.Runtime.State.AbsolutePath)
-			p.localLifetime(local_plugin_runtime)
+			p.fullDuplexLifetime(local_plugin_runtime)
 		})
 	}
 }

+ 0 - 2
internal/server/middleware.go

@@ -75,11 +75,9 @@ func (app *App) redirectPluginInvokeByPluginIdentifier(
 	nodes, err := app.cluster.FetchPluginAvailableNodesById(plugin_unique_identifier.String())
 	if err != nil {
 		ctx.AbortWithStatusJSON(500, gin.H{"error": "Internal server error"})
-		log.Error("fetch plugin available nodes failed: %s", err.Error())
 		return
 	} else if len(nodes) == 0 {
 		ctx.AbortWithStatusJSON(404, gin.H{"error": "No available node"})
-		log.Error("no available node")
 		return
 	}
 

+ 10 - 0
internal/types/models/curd/atomic.go

@@ -61,6 +61,16 @@ func CreatePlugin(
 			plugin_to_be_returns = &p
 		}
 
+		// remove exists installation
+		if err := db.DeleteByCondition(
+			models.PluginInstallation{
+				PluginID: plugin_to_be_returns.PluginID,
+			},
+			tx,
+		); err != nil {
+			return err
+		}
+
 		installation := &models.PluginInstallation{
 			PluginID:               plugin_to_be_returns.PluginID,
 			PluginUniqueIdentifier: plugin_to_be_returns.PluginUniqueIdentifier,