mod: redirect stderr of executed command for serve to log file
This commit is contained in:
@@ -56,6 +56,11 @@ func setupSshServer(host string, port string, host_key_path string, users map[st
|
|||||||
func(next ssh.Handler) ssh.Handler {
|
func(next ssh.Handler) ssh.Handler {
|
||||||
return func(s ssh.Session) {
|
return func(s ssh.Session) {
|
||||||
cmd := wish.Command(s, name, args...)
|
cmd := wish.Command(s, name, args...)
|
||||||
|
file, err := os.OpenFile("log", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
|
||||||
|
if err != nil {
|
||||||
|
wish.Fatalf(s, "Could not create or open log file. err: %w", err)
|
||||||
|
}
|
||||||
|
cmd.SetStderr(file)
|
||||||
if err := cmd.Run(); err != nil {
|
if err := cmd.Run(); err != nil {
|
||||||
wish.Fatalln(s, err)
|
wish.Fatalln(s, err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user