mirror of https://github.com/ouqiang/gocron
修复设置SSH超时无效
parent
ed54595b6d
commit
0e543331f6
|
@ -34,7 +34,7 @@ type Result struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseSSHConfig(sshConfig SSHConfig) (config *ssh.ClientConfig, err error) {
|
func parseSSHConfig(sshConfig SSHConfig) (config *ssh.ClientConfig, err error) {
|
||||||
timeout := SSHConnectTimeout * time.Second
|
timeout := time.Duration(SSHConnectTimeout) * time.Second
|
||||||
// 密码认证
|
// 密码认证
|
||||||
if sshConfig.AuthType == HostPassword {
|
if sshConfig.AuthType == HostPassword {
|
||||||
config = &ssh.ClientConfig{
|
config = &ssh.ClientConfig{
|
||||||
|
|
|
@ -158,7 +158,7 @@ func (h *SSHCommandHandler) Run(taskModel models.TaskHost) (string, error) {
|
||||||
sshConfig.User = hostModel.Username
|
sshConfig.User = hostModel.Username
|
||||||
sshConfig.Host = hostModel.Name
|
sshConfig.Host = hostModel.Name
|
||||||
sshConfig.Port = hostModel.Port
|
sshConfig.Port = hostModel.Port
|
||||||
sshConfig.ExecTimeout = 5
|
sshConfig.ExecTimeout = taskModel.Timeout
|
||||||
sshConfig.AuthType = hostModel.AuthType
|
sshConfig.AuthType = hostModel.AuthType
|
||||||
var password string
|
var password string
|
||||||
var privateKey string
|
var privateKey string
|
||||||
|
@ -204,7 +204,6 @@ func updateTaskLog(taskLogId int64, taskResult TaskResult) (int64, error) {
|
||||||
var status models.Status
|
var status models.Status
|
||||||
var result string = taskResult.Result
|
var result string = taskResult.Result
|
||||||
if taskResult.Err != nil {
|
if taskResult.Err != nil {
|
||||||
result = taskResult.Err.Error() + "\n" + result
|
|
||||||
status = models.Failure
|
status = models.Failure
|
||||||
} else {
|
} else {
|
||||||
status = models.Finish
|
status = models.Finish
|
||||||
|
|
Loading…
Reference in New Issue