Commit 979b5f8d authored by Hamdi Allam's avatar Hamdi Allam Committed by GitHub

make an rpc server an into a cliapp service (#11197)

parent 6f887d51
package rpc
import (
"context"
"sync/atomic"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum-optimism/optimism/op-service/cliapp"
)
var _ cliapp.Lifecycle = &Service{}
type Service struct {
log log.Logger
srv *Server
stopped atomic.Bool
}
func NewService(log log.Logger, srv *Server) *Service {
return &Service{log: log, srv: srv, stopped: atomic.Bool{}}
}
func (s *Service) Start(_ context.Context) error {
s.log.Info("starting rpc server")
return s.srv.Start()
}
func (s *Service) Stop(_ context.Context) error {
if s.stopped.Load() {
return nil
}
s.log.Info("stopping rpc server")
err := s.srv.Stop()
if err == nil {
s.stopped.Store(true)
}
return err
}
func (s *Service) Stopped() bool {
return s.stopped.Load()
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment