Skip to content

Commit

Permalink
feat: add random name prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Zxilly committed Jan 8, 2025
1 parent ef81cc4 commit 0c86c70
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion server/cmd/server/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/pkg/stdcopy"
"github.com/gorilla/websocket"

"github.com/Zxilly/playground-cj/server"
)

const (
Expand Down Expand Up @@ -44,14 +46,16 @@ func handleWebSocket(w http.ResponseWriter, r *http.Request) {
ctx, cancel := context.WithCancel(r.Context())
defer cancel()

name := "cangjie-lsp-" + server.RandomString(5)

resp, err := dockerClient.ContainerCreate(ctx, &container.Config{
Image: defaultImage,
OpenStdin: true,
StdinOnce: true,
AttachStdin: true,
AttachStdout: true,
Cmd: []string{"lsp"},
}, hostConfig, nil, nil, "")
}, hostConfig, nil, nil, name)
if err != nil {
log.Printf("Container creation failed: %v", err)
return
Expand Down

0 comments on commit 0c86c70

Please sign in to comment.