mirror of
https://gitee.com/dromara/mayfly-go
synced 2025-12-26 01:16:36 +08:00
feat: 数据库超时时间设置
This commit is contained in:
@@ -18,7 +18,7 @@ WORKDIR /mayfly
|
|||||||
# Copy the go source for building server
|
# Copy the go source for building server
|
||||||
COPY server .
|
COPY server .
|
||||||
|
|
||||||
RUN go mod download
|
RUN go mod tidy && go mod download
|
||||||
|
|
||||||
COPY --from=fe-builder /mayfly/dist /mayfly/static/static
|
COPY --from=fe-builder /mayfly/dist /mayfly/static/static
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ import { nextTick, onMounted, ref, toRefs, reactive, computed } from 'vue';
|
|||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
import { initRouter } from '@/router/index';
|
import { initRouter } from '@/router/index';
|
||||||
import { saveToken, saveUser, setSession } from '@/common/utils/storage';
|
import { saveToken, saveUser } from '@/common/utils/storage';
|
||||||
import { formatAxis } from '@/common/utils/format';
|
import { formatAxis } from '@/common/utils/format';
|
||||||
import openApi from '@/common/openApi';
|
import openApi from '@/common/openApi';
|
||||||
import { RsaEncrypt } from '@/common/rsa';
|
import { RsaEncrypt } from '@/common/rsa';
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ const viteConfig: UserConfig = {
|
|||||||
chunkSizeWarningLimit: 1500,
|
chunkSizeWarningLimit: 1500,
|
||||||
rollupOptions: {
|
rollupOptions: {
|
||||||
output: {
|
output: {
|
||||||
entryFileNames: `assets/[hash].[name].js`,
|
entryFileNames: `assets/[name]-[hash].js`,
|
||||||
chunkFileNames: `assets/[hash].[name].js`,
|
chunkFileNames: `assets/[name]-[hash].js`,
|
||||||
assetFileNames: `assets/[name].[hash].[ext]`,
|
assetFileNames: `assets/[name]-[hash].[ext]`,
|
||||||
compact: true,
|
compact: true,
|
||||||
manualChunks: {
|
manualChunks: {
|
||||||
vue: ['vue', 'vue-router', 'pinia'],
|
vue: ['vue', 'vue-router', 'pinia'],
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import (
|
|||||||
"mayfly-go/pkg/errorx"
|
"mayfly-go/pkg/errorx"
|
||||||
"mayfly-go/pkg/utils/anyx"
|
"mayfly-go/pkg/utils/anyx"
|
||||||
"mayfly-go/pkg/utils/collx"
|
"mayfly-go/pkg/utils/collx"
|
||||||
|
"mayfly-go/pkg/utils/netx"
|
||||||
"net"
|
"net"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@@ -41,7 +42,7 @@ func getPgsqlDB(d *DbInfo) (*sql.DB, error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dsn := fmt.Sprintf("host=%s port=%d user=%s password=%s %s sslmode=disable", d.Host, d.Port, d.Username, d.Password, dbParam)
|
dsn := fmt.Sprintf("host=%s port=%d user=%s password=%s %s sslmode=disable connect_timeout=8", d.Host, d.Port, d.Username, d.Password, dbParam)
|
||||||
// 存在额外指定参数,则拼接该连接参数
|
// 存在额外指定参数,则拼接该连接参数
|
||||||
if d.Params != "" {
|
if d.Params != "" {
|
||||||
// 存在指定的db,则需要将dbInstance配置中的parmas排除掉dbname和search_path
|
// 存在指定的db,则需要将dbInstance配置中的parmas排除掉dbname和search_path
|
||||||
@@ -79,7 +80,8 @@ func (pd *PqSqlDialer) Dial(network, address string) (net.Conn, error) {
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
if sshConn, err := sshTunnel.GetDialConn("tcp", address); err == nil {
|
if sshConn, err := sshTunnel.GetDialConn("tcp", address); err == nil {
|
||||||
return sshConn, nil
|
// 将ssh conn包装,否则会返回错误: ssh: tcpChan: deadline not supported
|
||||||
|
return &netx.WrapSshConn{Conn: sshConn}, nil
|
||||||
} else {
|
} else {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (c *WrapSshConn) RemoteAddr() net.Addr {
|
|||||||
return c.Conn.RemoteAddr()
|
return c.Conn.RemoteAddr()
|
||||||
}
|
}
|
||||||
func (c *WrapSshConn) SetDeadline(t time.Time) error {
|
func (c *WrapSshConn) SetDeadline(t time.Time) error {
|
||||||
return c.Conn.SetDeadline(t)
|
return nil
|
||||||
}
|
}
|
||||||
func (c *WrapSshConn) SetReadDeadline(t time.Time) error {
|
func (c *WrapSshConn) SetReadDeadline(t time.Time) error {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Reference in New Issue
Block a user