diff --git a/cli/connector/connector.go b/cli/connector/connector.go index 6050ea612..4eae24f41 100644 --- a/cli/connector/connector.go +++ b/cli/connector/connector.go @@ -3,6 +3,8 @@ package connector import ( "fmt" "net" + "os" + "path/filepath" "time" "github.com/tarantool/go-tarantool" @@ -37,6 +39,23 @@ type Connector interface { // Connect connects to the tarantool instance according to options. func Connect(opts ConnectOpts) (Connector, error) { + // It became common that address is longer than 108 symbols(sun_path limit). + // To reduce length of address we use relative path + // with chdir into a directory of socket. + // e.g foo/bar/123.sock -> ./123.sock + workDir, err := os.Getwd() + if err != nil { + return nil, err + } + if _, err := os.Stat(opts.Address); err == nil { + if len(opts.Address) > 108 { + return nil, fmt.Errorf("socket name is longer than 106 symbols: %s", + filepath.Base(opts.Address)) + } + os.Chdir(filepath.Dir(opts.Address)) + opts.Address = "./" + filepath.Base(opts.Address) + defer os.Chdir(workDir) + } // Connect to specified address. greetingConn, err := net.Dial(opts.Network, opts.Address) if err != nil { @@ -65,8 +84,8 @@ func Connect(opts ConnectOpts) (Connector, error) { addr := fmt.Sprintf("%s://%s", opts.Network, opts.Address) conn, err := tarantool.Connect(addr, tarantool.Opts{ - User: opts.Username, - Pass: opts.Password, + User: opts.Username, + Pass: opts.Password, SkipSchema: true, // We don't need a schema for eval requests. }) if err != nil {