Skip to content

Commit 0a5e009

Browse files
committed
[executor] Delay acquiring executor PID for IL
1 parent 9caa890 commit 0a5e009

2 files changed

Lines changed: 13 additions & 11 deletions

File tree

cmd/o2-aliecs-executor/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package main
2626

2727
import (
28+
"fmt"
2829
"os"
2930

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

5153
cfg, err := config.FromEnv()
5254
if err != nil {

common/logger/infologger/directhook.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ const INFOLOGGER_MAX_MESSAGE_SIZE = 1024
4444

4545
var (
4646
hostname string
47-
pid string
47+
Pid string
4848
username string
4949
)
5050

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

5353
func init() {
5454
var err error
55-
pid = fmt.Sprintf("%d", os.Getpid())
55+
Pid = fmt.Sprintf("%d", os.Getpid())
5656

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

115115
type DirectHook struct {
116-
il *sender
117-
system string
118-
facility string
119-
role string
116+
il *sender
117+
system string
118+
facility string
119+
role string
120120
}
121121

122122
func paddedAbstractSocket(name string) string {
@@ -147,10 +147,10 @@ func NewDirectHook(defaultSystem string, defaultFacility string) (*DirectHook, e
147147
return nil, fmt.Errorf("cannot instantiate InfoLogger hook on socket %s", socketPath)
148148
}
149149
return &DirectHook{
150-
il: sender,
151-
system: defaultSystem,
152-
facility: defaultFacility,
153-
role: hostname,
150+
il: sender,
151+
system: defaultSystem,
152+
facility: defaultFacility,
153+
role: hostname,
154154
}, nil
155155
}
156156

@@ -187,7 +187,7 @@ func (h *DirectHook) Fire(e *logrus.Entry) error {
187187
}
188188
payload["timestamp"] = utils.NewUnixTimestamp()
189189
payload["hostname"] = hostname
190-
payload["pid"] = pid
190+
payload["pid"] = Pid
191191
payload["username"] = username
192192

193193
if e.HasCaller() {

0 commit comments

Comments
 (0)