mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-11 02:59:34 -06:00
Removed utils file
This commit is contained in:
@@ -127,7 +127,7 @@ func Serve(ctx context.Context, version string, serverConfig ServerConfig, serve
|
||||
portAsString := strconv.Itoa(serverConfig.Port())
|
||||
hostPort := net.JoinHostPort(serverConfig.Host(), portAsString)
|
||||
|
||||
if IsPortInUse(hostPort) {
|
||||
if portInUse(hostPort) {
|
||||
portInUseError := fmt.Errorf("Port %s already in use.", portAsString)
|
||||
return portInUseError, nil
|
||||
}
|
||||
@@ -163,6 +163,16 @@ func Serve(ctx context.Context, version string, serverConfig ServerConfig, serve
|
||||
return
|
||||
}
|
||||
|
||||
func portInUse(hostPort string) bool {
|
||||
timeout := time.Second
|
||||
conn, _ := net.DialTimeout("tcp", hostPort, timeout)
|
||||
if conn != nil {
|
||||
defer conn.Close()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func newSessionBuilder(sqlEngine *sqle.Engine, username, email string, autocommit bool) server.SessionBuilder {
|
||||
return func(ctx context.Context, conn *mysql.Conn, host string) (sql.Session, *sql.IndexRegistry, *sql.ViewRegistry, error) {
|
||||
mysqlSess := sql.NewSession(host, conn.RemoteAddr().String(), conn.User, conn.ConnectionID)
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright 2019-2020 Dolthub, Inc.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package sqlserver
|
||||
|
||||
import (
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
func IsPortInUse(hostPort string) bool {
|
||||
timeout := time.Second
|
||||
conn, _ := net.DialTimeout("tcp", hostPort, timeout)
|
||||
if conn != nil {
|
||||
defer conn.Close()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
Reference in New Issue
Block a user