summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2023-01-06 13:49:04 +0100
committerValery Piashchynski <[email protected]>2023-01-06 13:49:04 +0100
commit3bb4d3a497b609557e884ec29a94c204dfac86a2 (patch)
tree79efa8e3a9fdb626462a5236265c298f36f77e2e /internal
parentf6bc8835dc4d996992b6d4a2751ac10dc6138e4f (diff)
Initial support for the endure v2 container
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'internal')
-rw-r--r--internal/cli/serve/command.go22
-rw-r--r--internal/cli/workers/command.go2
-rw-r--r--internal/cli/workers/render.go7
3 files changed, 21 insertions, 10 deletions
diff --git a/internal/cli/serve/command.go b/internal/cli/serve/command.go
index dcaadec5..a4ee2189 100644
--- a/internal/cli/serve/command.go
+++ b/internal/cli/serve/command.go
@@ -6,6 +6,7 @@ import (
"os/signal"
"syscall"
+ "github.com/roadrunner-server/endure/v2"
"github.com/roadrunner-server/roadrunner/v2/container"
"github.com/roadrunner-server/roadrunner/v2/internal/meta"
@@ -44,26 +45,31 @@ func NewCommand(override *[]string, cfgFile *string, silent *bool) *cobra.Comman
Version: meta.Version(),
}
- // create endure container
- endureContainer, err := container.NewContainer(*containerCfg)
- if err != nil {
- return errors.E(op, err)
+ endureOptions := []endure.Options{
+ endure.GracefulShutdownTimeout(containerCfg.GracePeriod),
}
+ if containerCfg.PrintGraph {
+ endureOptions = append(endureOptions, endure.Visualize())
+ }
+
+ // create endure container
+ cont := endure.New(containerCfg.LogLevel, endureOptions...)
+
// register plugins
- err = endureContainer.RegisterAll(append(container.Plugins(), cfg)...)
+ err = cont.RegisterAll(append(container.Plugins(), cfg)...)
if err != nil {
return errors.E(op, err)
}
// init container and all services
- err = endureContainer.Init()
+ err = cont.Init()
if err != nil {
return errors.E(op, err)
}
// start serving the graph
- errCh, err := endureContainer.Serve()
+ errCh, err := cont.Serve()
if err != nil {
return errors.E(op, err)
}
@@ -95,7 +101,7 @@ func NewCommand(override *[]string, cfgFile *string, silent *bool) *cobra.Comman
case <-stop: // stop the container after first signal
fmt.Printf("stop signal received, grace timeout is: %0.f seconds\n", containerCfg.GracePeriod.Seconds())
- if err = endureContainer.Stop(); err != nil {
+ if err = cont.Stop(); err != nil {
return fmt.Errorf("error: %w", err)
}
diff --git a/internal/cli/workers/command.go b/internal/cli/workers/command.go
index d65a454a..caee83ac 100644
--- a/internal/cli/workers/command.go
+++ b/internal/cli/workers/command.go
@@ -8,8 +8,8 @@ import (
"syscall"
"time"
+ "github.com/roadrunner-server/api/v3/plugins/v1/jobs"
internalRpc "github.com/roadrunner-server/roadrunner/v2/internal/rpc"
- "github.com/roadrunner-server/sdk/v3/plugins/jobs"
tm "github.com/buger/goterm"
"github.com/fatih/color"
diff --git a/internal/cli/workers/render.go b/internal/cli/workers/render.go
index a0810b21..28b94c56 100644
--- a/internal/cli/workers/render.go
+++ b/internal/cli/workers/render.go
@@ -2,13 +2,14 @@ package workers
import (
"io"
+ "sort"
"strconv"
"time"
"github.com/dustin/go-humanize"
"github.com/fatih/color"
"github.com/olekukonko/tablewriter"
- "github.com/roadrunner-server/sdk/v3/plugins/jobs"
+ "github.com/roadrunner-server/api/v3/plugins/v1/jobs"
"github.com/roadrunner-server/sdk/v3/state/process"
)
@@ -19,6 +20,10 @@ const (
// WorkerTable renders table with information about rr server workers.
func WorkerTable(writer io.Writer, workers []*process.State) *tablewriter.Table {
+ sort.Slice(workers, func(i, j int) bool {
+ return workers[i].Pid < workers[j].Pid
+ })
+
tw := tablewriter.NewWriter(writer)
tw.SetHeader([]string{"PID", "Status", "Execs", "Memory", "CPU%", "Created"})
tw.SetColMinWidth(0, 7)