diff options
author | Valery Piashchynski <[email protected]> | 2023-01-06 13:49:04 +0100 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2023-01-06 13:49:04 +0100 |
commit | 3bb4d3a497b609557e884ec29a94c204dfac86a2 (patch) | |
tree | 79efa8e3a9fdb626462a5236265c298f36f77e2e /lib | |
parent | f6bc8835dc4d996992b6d4a2751ac10dc6138e4f (diff) |
Initial support for the endure v2 container
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/roadrunner.go | 18 | ||||
-rw-r--r-- | lib/roadrunner_test.go | 9 |
2 files changed, 11 insertions, 16 deletions
diff --git a/lib/roadrunner.go b/lib/roadrunner.go index 8a505c3f..d500dc66 100644 --- a/lib/roadrunner.go +++ b/lib/roadrunner.go @@ -5,8 +5,7 @@ import ( "runtime/debug" configImpl "github.com/roadrunner-server/config/v3" - endure "github.com/roadrunner-server/endure/pkg/container" - "github.com/roadrunner-server/endure/pkg/fsm" + "github.com/roadrunner-server/endure/v2" "github.com/roadrunner-server/roadrunner/v2/container" ) @@ -38,11 +37,16 @@ func NewRR(cfgFile string, override []string, pluginList []any) (*RR, error) { } // create endure container - endureContainer, err := container.NewContainer(*containerCfg) - if err != nil { - return nil, err + endureOptions := []endure.Options{ + endure.GracefulShutdownTimeout(containerCfg.GracePeriod), } + if containerCfg.PrintGraph { + endureOptions = append(endureOptions, endure.Visualize()) + } + + endureContainer := endure.New(containerCfg.LogLevel, endureOptions...) + // register another container plugins err = endureContainer.RegisterAll(append(pluginList, cfg)...) if err != nil { @@ -79,8 +83,8 @@ func (rr *RR) Serve() error { } } -func (rr *RR) CurrentState() fsm.State { - return rr.container.CurrentState() +func (rr *RR) Plugins() []string { + return rr.container.Plugins() } // Stop stops roadrunner diff --git a/lib/roadrunner_test.go b/lib/roadrunner_test.go index 9ed7c80a..d25e7380 100644 --- a/lib/roadrunner_test.go +++ b/lib/roadrunner_test.go @@ -5,7 +5,6 @@ import ( "testing" "time" - "github.com/roadrunner-server/endure/pkg/fsm" "github.com/roadrunner-server/informer/v3" "github.com/roadrunner-server/resetter/v3" "github.com/roadrunner-server/roadrunner/v2/lib" @@ -40,7 +39,6 @@ func TestNewWithConfig(t *testing.T) { assert.NoError(t, err) assert.Equal(t, "2", string(rr.Version[0])) - assert.Equal(t, fsm.Initialized, rr.CurrentState()) t.Cleanup(func() { _ = os.Remove(cfgFile) @@ -64,16 +62,9 @@ func TestServeStop(t *testing.T) { stopchan <- struct{}{} }() - assert.Equal(t, rr.CurrentState(), fsm.Initialized) - - for rr.CurrentState() != fsm.Started { - time.Sleep(20 * time.Millisecond) - } - rr.Stop() time.Sleep(time.Second * 2) - assert.Equal(t, fsm.Stopped, rr.CurrentState()) assert.Equal(t, struct{}{}, <-stopchan) assert.Nil(t, <-errchan) |