commit
9d92bff527
@ -0,0 +1,8 @@
|
||||
[Error]2020/08/24 16:43:34 SqlQueryError sql: expected 1 arguments, got 3
|
||||
[Error]2020/08/24 16:44:31 SqlQueryError sql: expected 1 arguments, got 3
|
||||
[Error]2020/08/24 16:49:43 SqlQueryError sql: expected 1 arguments, got 3
|
||||
[Error]2020/08/24 16:49:43 SqlQueryError WRONGTYPE Operation against a key holding the wrong kind of value
|
||||
[Error]2020/08/24 16:59:45 SqlQueryError sql: expected 1 arguments, got 3
|
||||
[Error]2020/08/24 16:59:45 SqlQueryError WRONGTYPE Operation against a key holding the wrong kind of value
|
||||
[Error]2020/08/24 17:16:04 SqlQueryError sql: expected 1 arguments, got 3
|
||||
[Error]2020/08/24 17:16:04 SqlQueryError WRONGTYPE Operation against a key holding the wrong kind of value
|
After Width: | Height: | Size: 453 KiB |
After Width: | Height: | Size: 453 KiB |
After Width: | Height: | Size: 453 KiB |
@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 杀掉进程
|
||||
kill -9 `pgrep -f dsSupport` 2>/dev/null
|
||||
sleep 3
|
||||
|
||||
cd /usr/local/dsMin/dsSupport
|
||||
chmod +x dsSupport
|
||||
# 运行为后台进程1
|
||||
/usr/local/dsMin/dsSupport/dsSupport
|
@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 杀掉进程
|
||||
kill -9 `pgrep -f dsSupport` 2>/dev/null
|
||||
sleep 3
|
||||
|
||||
chmod +x dsBaseWeb
|
||||
# 运行为后台进程
|
||||
nohup /usr/local/dsMin/dsSupport/dsSupport >> /usr/local/dsMin/dsSupport/dsSupport.log 2>&1 &
|
@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# kill 命令不使用 -9 参数时,会回调 onStop() 方法,确定不需要此回调建议使用 -9 参数
|
||||
kill -9 `pgrep -f dsSupport` 2>/dev/null
|
Binary file not shown.
@ -0,0 +1,95 @@
|
||||
package SftpUtil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/pkg/sftp"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Connect(user, password, host string, port int) (*sftp.Client, error) {
|
||||
var (
|
||||
auth []ssh.AuthMethod
|
||||
addr string
|
||||
clientConfig *ssh.ClientConfig
|
||||
sshClient *ssh.Client
|
||||
sftpClient *sftp.Client
|
||||
err error
|
||||
)
|
||||
// get auth method
|
||||
auth = make([]ssh.AuthMethod, 0)
|
||||
auth = append(auth, ssh.Password(password))
|
||||
|
||||
clientConfig = &ssh.ClientConfig{
|
||||
User: user,
|
||||
Auth: auth,
|
||||
Timeout: 30 * time.Second,
|
||||
HostKeyCallback: ssh.InsecureIgnoreHostKey(), //ssh.FixedHostKey(hostKey),
|
||||
}
|
||||
|
||||
// connet to ssh
|
||||
addr = fmt.Sprintf("%s:%d", host, port)
|
||||
if sshClient, err = ssh.Dial("tcp", addr, clientConfig); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// create sftp client
|
||||
if sftpClient, err = sftp.NewClient(sshClient); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return sftpClient, nil
|
||||
}
|
||||
|
||||
func UploadFile(sftpClient *sftp.Client, localFilePath string, remotePath string) {
|
||||
srcFile, err := os.Open(localFilePath)
|
||||
if err != nil {
|
||||
fmt.Println("os.Open error : ", localFilePath)
|
||||
log.Fatal(err)
|
||||
|
||||
}
|
||||
defer srcFile.Close()
|
||||
//golang中path.Base(pathString)函数,pathString的值必须为 linux 风格的路径,即 "/" 才能够正常的获取最后的路径段的值。
|
||||
localFilePath = filepath.ToSlash(localFilePath)
|
||||
var remoteFileName = path.Base(localFilePath)
|
||||
|
||||
dstFile, err := sftpClient.Create(path.Join(remotePath, remoteFileName))
|
||||
if err != nil {
|
||||
fmt.Println("sftpClient.Create error : ", path.Join(remotePath, remoteFileName))
|
||||
log.Fatal(err)
|
||||
|
||||
}
|
||||
defer dstFile.Close()
|
||||
|
||||
ff, err := ioutil.ReadAll(srcFile)
|
||||
if err != nil {
|
||||
fmt.Println("ReadAll error : ", localFilePath)
|
||||
log.Fatal(err)
|
||||
|
||||
}
|
||||
dstFile.Write(ff)
|
||||
fmt.Println(localFilePath + " copy file to remote server finished!")
|
||||
}
|
||||
|
||||
func UploadDirectory(sftpClient *sftp.Client, localPath string, remotePath string) {
|
||||
localFiles, err := ioutil.ReadDir(localPath)
|
||||
if err != nil {
|
||||
log.Fatal("read dir list fail ", err)
|
||||
}
|
||||
for _, backupDir := range localFiles {
|
||||
localFilePath := path.Join(localPath, backupDir.Name())
|
||||
remoteFilePath := path.Join(remotePath, backupDir.Name())
|
||||
if backupDir.IsDir() {
|
||||
sftpClient.Mkdir(remoteFilePath)
|
||||
UploadDirectory(sftpClient, localFilePath, remoteFilePath)
|
||||
} else {
|
||||
UploadFile(sftpClient, path.Join(localPath, backupDir.Name()), remotePath)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println(localPath + " copy directory to remote server finished!")
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package SshUtil
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"golang.org/x/crypto/ssh"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Cli struct {
|
||||
IP string
|
||||
Username string
|
||||
Password string
|
||||
Port int
|
||||
client *ssh.Client
|
||||
LastResult string
|
||||
}
|
||||
|
||||
func New(ip string, username string, password string, port ...int) *Cli {
|
||||
cli := new(Cli)
|
||||
cli.IP = ip
|
||||
cli.Username = username
|
||||
cli.Password = password
|
||||
if len(port) <= 0 {
|
||||
cli.Port = 22
|
||||
} else {
|
||||
cli.Port = port[0]
|
||||
}
|
||||
return cli
|
||||
}
|
||||
|
||||
func (c Cli) Run(shell string) (string, error) {
|
||||
if c.client == nil {
|
||||
if err := c.connect(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
session, err := c.client.NewSession()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
defer session.Close()
|
||||
buf, err := session.CombinedOutput(shell)
|
||||
|
||||
c.LastResult = string(buf)
|
||||
return c.LastResult, err
|
||||
}
|
||||
//连接
|
||||
func (c *Cli) connect() error {
|
||||
config := ssh.ClientConfig{
|
||||
User: c.Username,
|
||||
Auth: []ssh.AuthMethod{ssh.Password(c.Password)},
|
||||
HostKeyCallback: func(hostname string, remote net.Addr, key ssh.PublicKey) error {
|
||||
return nil
|
||||
},
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
addr := fmt.Sprintf("%s:%d", c.IP, c.Port)
|
||||
sshClient, err := ssh.Dial("tcp", addr, &config)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.client = sshClient
|
||||
return nil
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
:: 创建Windows发布版本 -ldflags "-s -w"
|
||||
go build -o ./WinBuild/Distribute.exe ./Tools/Distribute.go
|
||||
|
||||
:: 创建Linux发布版本
|
||||
SET GOOS=linux
|
||||
SET GOARCH=amd64
|
||||
go build -gcflags "all=-N -l" -o ./build/dsSupport main.go
|
||||
|
||||
:: 拷贝资源文件
|
||||
xcopy .\Shell\* .\build\ /y /e /i /q
|
||||
xcopy .\docs\* .\build\docs /y /e /i /q
|
||||
xcopy .\Config\* .\build\Config /y /e /i /q
|
||||
|
||||
:: 上传文件
|
||||
.\WinBuild\Distribute.exe
|
||||
|
||||
pause
|
Loading…
Reference in new issue