Skip to content

Commit

Permalink
[executor] Delay acquiring executor PID for IL
Browse files Browse the repository at this point in the history
  • Loading branch information
teo committed Dec 13, 2023
1 parent 9caa890 commit 0a5e009
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
2 changes: 2 additions & 0 deletions cmd/o2-aliecs-executor/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package main

import (
"fmt"
"os"

"github.com/AliceO2Group/Control/common/logger"
Expand All @@ -47,6 +48,7 @@ var log = logger.New(logrus.StandardLogger(), "executor")
// Entry point, reads configuration from environment variables.
func main() {
logrus.SetLevel(logrus.DebugLevel)
infologger.Pid = fmt.Sprintf("%d", os.Getpid())

cfg, err := config.FromEnv()
if err != nil {
Expand Down
22 changes: 11 additions & 11 deletions common/logger/infologger/directhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ const INFOLOGGER_MAX_MESSAGE_SIZE = 1024

var (
hostname string
pid string
Pid string
username string
)

var lineBreaksRe = regexp.MustCompile(`\r?\n`)

func init() {
var err error
pid = fmt.Sprintf("%d", os.Getpid())
Pid = fmt.Sprintf("%d", os.Getpid())

unixUser, _ := user.Current()
if unixUser != nil {
Expand Down Expand Up @@ -113,10 +113,10 @@ func (s *sender) Send(fields map[string]string) error {
}

type DirectHook struct {
il *sender
system string
facility string
role string
il *sender
system string
facility string
role string
}

func paddedAbstractSocket(name string) string {
Expand Down Expand Up @@ -147,10 +147,10 @@ func NewDirectHook(defaultSystem string, defaultFacility string) (*DirectHook, e
return nil, fmt.Errorf("cannot instantiate InfoLogger hook on socket %s", socketPath)
}
return &DirectHook{
il: sender,
system: defaultSystem,
facility: defaultFacility,
role: hostname,
il: sender,
system: defaultSystem,
facility: defaultFacility,
role: hostname,
}, nil
}

Expand Down Expand Up @@ -187,7 +187,7 @@ func (h *DirectHook) Fire(e *logrus.Entry) error {
}
payload["timestamp"] = utils.NewUnixTimestamp()
payload["hostname"] = hostname
payload["pid"] = pid
payload["pid"] = Pid
payload["username"] = username

if e.HasCaller() {
Expand Down

0 comments on commit 0a5e009

Please sign in to comment.