TUN-3195: Don't colorize console logs when stderr is not a terminal

This commit is contained in:
Igor Postelnik
2021-01-21 17:03:47 -06:00
parent a129572749
commit ce22dd681a
230 changed files with 13100 additions and 5789 deletions

View File

@@ -98,6 +98,12 @@ func (s *Service) Config() (Config, error) {
delayedStart = true
}
b, err = s.queryServiceConfig2(windows.SERVICE_CONFIG_SERVICE_SID_INFO)
if err != nil {
return Config{}, err
}
sidType := *(*uint32)(unsafe.Pointer(&b[0]))
return Config{
ServiceType: p.ServiceType,
StartType: p.StartType,
@@ -110,6 +116,7 @@ func (s *Service) Config() (Config, error) {
DisplayName: windows.UTF16PtrToString(p.DisplayName),
Description: windows.UTF16PtrToString(p2.Description),
DelayedAutoStart: delayedStart,
SidType: sidType,
}, nil
}

View File

@@ -117,9 +117,6 @@ func (m *Mgr) CreateService(name, exepath string, c Config, args ...string) (*Se
if c.StartType == 0 {
c.StartType = StartManual
}
if c.ErrorControl == 0 {
c.ErrorControl = ErrorNormal
}
if c.ServiceType == 0 {
c.ServiceType = windows.SERVICE_WIN32_OWN_PROCESS
}

View File

@@ -68,8 +68,10 @@ func (s *Service) Query() (svc.Status, error) {
return svc.Status{}, err
}
return svc.Status{
State: svc.State(t.CurrentState),
Accepts: svc.Accepted(t.ControlsAccepted),
ProcessId: t.ProcessId,
State: svc.State(t.CurrentState),
Accepts: svc.Accepted(t.ControlsAccepted),
ProcessId: t.ProcessId,
Win32ExitCode: t.Win32ExitCode,
ServiceSpecificExitCode: t.ServiceSpecificExitCode,
}, nil
}