Skip to content

Commit

Permalink
修正使用supervisor后无法获取用户私钥的问题(配置文件增加私钥路径配置)
Browse files Browse the repository at this point in the history
  • Loading branch information
mylxsw committed May 6, 2017
1 parent 14cf7e7 commit 22deabe
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
12 changes: 7 additions & 5 deletions command/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package command
import (
"bufio"
"fmt"
"github.com/mylxsw/remote-tail/console"
"github.com/mylxsw/remote-tail/ssh"
"io"
"strconv"
"strings"
"sync"

"github.com/mylxsw/remote-tail/console"
"github.com/mylxsw/remote-tail/ssh"
)

type Command struct {
Expand Down Expand Up @@ -46,9 +47,10 @@ func NewCommand(server Server) (cmd *Command) {
func (cmd *Command) Execute(output chan Message) {

client := &ssh.Client{
Host: cmd.Host,
User: cmd.User,
Password: cmd.Server.Password,
Host: cmd.Host,
User: cmd.User,
Password: cmd.Server.Password,
PrivateKeyPath: cmd.Server.PrivateKeyPath,
}

if err := client.Connect(); err != nil {
Expand Down
13 changes: 7 additions & 6 deletions command/config.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package command

type Server struct {
ServerName string `toml:"server_name"`
Hostname string `toml:"hostname"`
Port int `toml:"port"`
User string `toml:"user"`
Password string `toml:"password"`
TailFile string `toml:"tail_file"`
ServerName string `toml:"server_name"`
Hostname string `toml:"hostname"`
Port int `toml:"port"`
User string `toml:"user"`
Password string `toml:"password"`
PrivateKeyPath string `toml:"private_key_path"`
TailFile string `toml:"tail_file"`
}

type Config struct {
Expand Down
2 changes: 1 addition & 1 deletion example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tail_file="/data/logs/laravel.log"
slient=false

# 服务器配置,可以配置多个
# 如果不提供password,则使用当前用户的ssh公钥,建议采用该方式,使用密码方式不安全
# 如果不提供password,则使用当前用户的ssh公钥(private_key_path=/home/mylxsw/.ssh/id_rsa),建议采用该方式,使用密码方式不安全
# server_name, hostname, user 配置为必选,其它可选
[servers]

Expand Down
9 changes: 9 additions & 0 deletions supervisor-remote-tail.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[program:remote-tail-example]
process_name=%(program_name)s_%(process_num)02d
command=remote-tail -conf=/usr/local/etc/remote-tail/example.toml
autostart=true
autorestart=true
user=root
numprocs=1
redirect_stderr=true
stdout_logfile=/data/logs/example.log

0 comments on commit 22deabe

Please sign in to comment.