projects
/
arvados.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch '14916-rubysdk-upgrade-note'
[arvados.git]
/
lib
/
service
/
cmd.go
diff --git
a/lib/service/cmd.go
b/lib/service/cmd.go
index 7f6b0236cb9571cd3ca30420cb6d41af6d787bd3..d99af0eea15428054fd5adc16596ca89b1de7820 100644
(file)
--- a/
lib/service/cmd.go
+++ b/
lib/service/cmd.go
@@
-6,6
+6,7
@@
package service
import (
package service
import (
+ "context"
"flag"
"fmt"
"io"
"flag"
"fmt"
"io"
@@
-14,6
+15,7
@@
import (
"git.curoverse.com/arvados.git/lib/cmd"
"git.curoverse.com/arvados.git/sdk/go/arvados"
"git.curoverse.com/arvados.git/lib/cmd"
"git.curoverse.com/arvados.git/sdk/go/arvados"
+ "git.curoverse.com/arvados.git/sdk/go/ctxlog"
"git.curoverse.com/arvados.git/sdk/go/httpserver"
"github.com/coreos/go-systemd/daemon"
"github.com/sirupsen/logrus"
"git.curoverse.com/arvados.git/sdk/go/httpserver"
"github.com/coreos/go-systemd/daemon"
"github.com/sirupsen/logrus"
@@
-24,7
+26,7
@@
type Handler interface {
CheckHealth() error
}
CheckHealth() error
}
-type NewHandlerFunc func(*arvados.Cluster, *arvados.NodeProfile) Handler
+type NewHandlerFunc func(
context.Context,
*arvados.Cluster, *arvados.NodeProfile) Handler
type command struct {
newHandler NewHandlerFunc
type command struct {
newHandler NewHandlerFunc
@@
-45,11
+47,7
@@
func Command(svcName arvados.ServiceName, newHandler NewHandlerFunc) cmd.Handler
}
func (c *command) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
}
func (c *command) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
- log := logrus.New()
- log.Formatter = &logrus.JSONFormatter{
- TimestampFormat: rfc3339NanoFixed,
- }
- log.Out = stderr
+ log := ctxlog.New(stderr, "json", "info")
var err error
defer func() {
var err error
defer func() {
@@
-76,6
+74,10
@@
func (c *command) RunCommand(prog string, args []string, stdin io.Reader, stdout
if err != nil {
return 1
}
if err != nil {
return 1
}
+ log = ctxlog.New(stderr, cluster.Logging.Format, cluster.Logging.Level).WithFields(logrus.Fields{
+ "PID": os.Getpid(),
+ })
+ ctx := ctxlog.Context(context.Background(), log)
profileName := *nodeProfile
if profileName == "" {
profileName = os.Getenv("ARVADOS_NODE_PROFILE")
profileName := *nodeProfile
if profileName == "" {
profileName = os.Getenv("ARVADOS_NODE_PROFILE")
@@
-89,7
+91,7
@@
func (c *command) RunCommand(prog string, args []string, stdin io.Reader, stdout
err = fmt.Errorf("configuration does not enable the %s service on this host", c.svcName)
return 1
}
err = fmt.Errorf("configuration does not enable the %s service on this host", c.svcName)
return 1
}
- handler := c.newHandler(cluster, profile)
+ handler := c.newHandler(c
tx, c
luster, profile)
if err = handler.CheckHealth(); err != nil {
return 1
}
if err = handler.CheckHealth(); err != nil {
return 1
}