func NewCommand(cfgPlugin *config.Viper) *cobra.Command {  
	return &cobra.Command{
		Use:   "serve",
		Short: "Start RoadRunner server",
		RunE: func(*cobra.Command, []string) error {
			const op = errors.Op("handle_serve_command")
			containerCfg, err := container.NewConfig(cfgPlugin)
			if err != nil {
				return errors.E(op, err)
			}
			cfgPlugin.CommonConfig = &config.General{GracefulTimeout: containerCfg.GracePeriod}
			endureContainer, err := container.NewContainer(*containerCfg)
			if err != nil {
				return errors.E(op, err)
			}
			if err = endureContainer.Register(cfgPlugin); err != nil {
				return errors.E(op, err)
			}
			for i, plugins := 0, container.Plugins(); i < len(plugins); i++ {
				if err = endureContainer.Register(plugins[i]); err != nil {
					return errors.E(op, err)
				}
			}
			if err = endureContainer.Init(); err != nil {
				return errors.E(op, err)
			}
			errCh, err := endureContainer.Serve()
			if err != nil {
				return errors.E(op, err)
			}
			oss, stop := make(chan os.Signal, 2), make(chan struct{}, 1)  
			signal.Notify(oss, os.Interrupt, syscall.SIGTERM, syscall.SIGINT)
			go func() {
				<-oss
				stop <- struct{}{}
				<-oss
				fmt.Println("exit forced")
				os.Exit(1)
			}()
			for {
				select {
				case e := <-errCh:
					fmt.Printf("error occurred: %v, plugin: %s\n", e.Error, e.VertexID)
					if !containerCfg.RetryOnFail {
						return errors.E(op, e.Error)
					}
				case <-stop:  
					fmt.Printf("stop signal received, grace timeout is: %d seconds\n", uint64(containerCfg.GracePeriod.Seconds()))
					if err = endureContainer.Stop(); err != nil {
						fmt.Printf("error occurred during the stopping container: %v\n", err)
					}
					return nil
				}
			}
		},
	}
}
NewCommand creates `serve` command.
package serve
import (
	"fmt"
	"os"
	"os/signal"
	"syscall"
	"github.com/spiral/roadrunner-binary/v2/internal/container"
	"github.com/spf13/cobra"
	"github.com/spiral/errors"
	"github.com/spiral/roadrunner-plugins/v2/config"
)