func (bs *BaseService) Start() (bool, error) {
	if atomic.CompareAndSwapUint32(&bs.start, 0, 1) {
		if atomic.LoadUint32(&bs.stopped) == 1 {
			logging.WithField("bsname", bs.name).Info("not starting baseservice -- already stopped")
			return false, nil
		} else {
			logging.WithField("bsname", bs.name).Info("starting service")
		}
		err := bs.impl.OnStart()
		if err != nil {
			atomic.StoreUint32(&bs.start, 0)
			return false, err
		}
		atomic.StoreUint32(&bs.started, 1)
		return true, err
	} else {
		logging.WithField("bsname", bs.name).Debug("not starting baseservice -- already stopped")
		return false, nil
	}
}
Start implements Service
package dkgnode
import (
	"sync/atomic"
	logging "github.com/sirupsen/logrus"
)
type ServiceCore interface {
	Name() string
	OnStart() error
	OnStop() error
	Call(method string, args ...interface{}) (result interface{}, err error)
	SetBaseService(*BaseService)
}
type Service interface {
	Start() error
	Stop() error
	IsRunning() bool
	SetServiceCore(ServiceCore)
	String() string
}
type BaseService struct {
	name    string
	start   uint32  
	started uint32  
	stopped uint32  
	quit    chan struct{}
	impl ServiceCore
}
func NewBaseService(impl ServiceCore) *BaseService {
	bs := &BaseService{
		name: impl.Name(),
		quit: make(chan struct{}),
		impl: impl,
	}
	bs.impl.SetBaseService(bs)
	return bs
}
func (bs *BaseService) Name() string {
	return bs.impl.Name()
}
func (bs *BaseService) Call(method string, args ...interface{}) (interface{}, error) {
	return bs.impl.Call(method, args...)
}