Enable syslog server and universal collector for windows

This commit is contained in:
Michal Wieczorek 2016-09-04 23:03:36 +02:00
parent f53108713b
commit 94071fc294
8 changed files with 10 additions and 95 deletions

View File

@ -1,11 +1,12 @@
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
package executor
import (
"fmt"
"io"
"log/syslog"
syslog "github.com/RackSec/srslog"
"github.com/hashicorp/nomad/client/driver/logging"
)

View File

@ -1,5 +0,0 @@
package executor
func (e *UniversalExecutor) LaunchSyslogServer(ctx *ExecutorContext) (*SyslogServerState, error) {
return nil, nil
}

View File

@ -1,71 +0,0 @@
package logging
import (
"log"
"github.com/hashicorp/nomad/client/allocdir"
cstructs "github.com/hashicorp/nomad/client/driver/structs"
"github.com/hashicorp/nomad/nomad/structs"
)
// LogCollectorContext holds context to configure the syslog server
type LogCollectorContext struct {
// TaskName is the name of the Task
TaskName string
// AllocDir is the handle to do operations on the alloc dir of
// the task
AllocDir *allocdir.AllocDir
// LogConfig provides configuration related to log rotation
LogConfig *structs.LogConfig
// PortUpperBound is the upper bound of the ports that we can use to start
// the syslog server
PortUpperBound uint
// PortLowerBound is the lower bound of the ports that we can use to start
// the syslog server
PortLowerBound uint
}
// SyslogCollectorState holds the address and islation information of a launched
// syslog server
type SyslogCollectorState struct {
IsolationConfig *cstructs.IsolationConfig
Addr string
}
// LogCollector is an interface which allows a driver to launch a log server
// and update log configuration
type LogCollector interface {
LaunchCollector(ctx *LogCollectorContext) (*SyslogCollectorState, error)
Exit() error
UpdateLogConfig(logConfig *structs.LogConfig) error
}
// SyslogCollector is a LogCollector which starts a syslog server and does
// rotation to incoming stream
type SyslogCollector struct {
}
// NewSyslogCollector returns an implementation of the SyslogCollector
func NewSyslogCollector(logger *log.Logger) *SyslogCollector {
return &SyslogCollector{}
}
// LaunchCollector launches a new syslog server and starts writing log lines to
// files and rotates them
func (s *SyslogCollector) LaunchCollector(ctx *LogCollectorContext) (*SyslogCollectorState, error) {
return nil, nil
}
// Exit kills the syslog server
func (s *SyslogCollector) Exit() error {
return nil
}
// UpdateLogConfig updates the log configuration
func (s *SyslogCollector) UpdateLogConfig(logConfig *structs.LogConfig) error {
return nil
}

View File

@ -1,12 +1,13 @@
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
package logging
import (
"fmt"
"log"
"log/syslog"
"strconv"
syslog "github.com/RackSec/srslog"
)
// Errors related to parsing priority

View File

@ -5,9 +5,10 @@ package logging
import (
"bytes"
"log"
"log/syslog"
"os"
"testing"
syslog "github.com/RackSec/srslog"
)
func TestLogParser_Priority(t *testing.T) {

View File

@ -1,5 +1,3 @@
// +build !windows
package logging
import (

View File

@ -1,10 +0,0 @@
package logging
type SyslogServer struct {
}
func (s *SyslogServer) Shutdown() {
}
type SyslogMessage struct {
}

View File

@ -1,4 +1,4 @@
// +build darwin dragonfly freebsd linux netbsd openbsd solaris
// +build darwin dragonfly freebsd linux netbsd openbsd solaris windows
package logging
@ -7,11 +7,11 @@ import (
"io"
"io/ioutil"
"log"
"log/syslog"
"net"
"os"
"runtime"
syslog "github.com/RackSec/srslog"
"github.com/hashicorp/nomad/client/allocdir"
cstructs "github.com/hashicorp/nomad/client/driver/structs"
"github.com/hashicorp/nomad/nomad/structs"