Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module github.com/langgenius/dify-sandbox

go 1.24.0

toolchain go1.23.3

require (
github.com/gin-gonic/gin v1.10.0
github.com/google/uuid v1.6.0
Expand Down
16 changes: 11 additions & 5 deletions internal/core/runner/nodejs/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"os"
"path"
"sync"

"github.com/langgenius/dify-sandbox/internal/utils/log"
)
Expand All @@ -17,6 +18,8 @@ const (

//go:embed nodejs.so
var nodejs_lib []byte
var libAvailableOnce sync.Once
var libAvailableResult bool

//go:embed dependens
var nodejs_dependens embed.FS // it's a directory
Expand Down Expand Up @@ -85,9 +88,12 @@ func releaseLibBinary() {
}

func checkLibAvaliable() bool {
if _, err := os.Stat(path.Join(LIB_PATH, LIB_NAME)); err != nil {
return false
}

return true
libAvailableOnce.Do(func() {
if _, err := os.Stat(path.Join(LIB_PATH, LIB_NAME)); err != nil {
libAvailableResult = false
return
}
libAvailableResult = true
})
return libAvailableResult
}
16 changes: 11 additions & 5 deletions internal/core/runner/python/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"path"
"regexp"
"strings"
"sync"

"github.com/langgenius/dify-sandbox/internal/static"

Expand All @@ -19,6 +20,8 @@ import (

//go:embed python.so
var python_lib []byte
var libAvailableOnce sync.Once
var libAvailableResult bool

const (
LIB_PATH = "/var/sandbox/sandbox-python"
Expand Down Expand Up @@ -63,11 +66,14 @@ func releaseLibBinary(force_remove_old_lib bool) {
}

func checkLibAvaliable() bool {
if _, err := os.Stat(path.Join(LIB_PATH, LIB_NAME)); err != nil {
return false
}

return true
libAvailableOnce.Do(func() {
if _, err := os.Stat(path.Join(LIB_PATH, LIB_NAME)); err != nil {
libAvailableResult = false
return
}
libAvailableResult = true
})
return libAvailableResult
}

func ExtractOnelineDepency(dependency string) (string, string) {
Expand Down