func (s *server) Stop() error {
	if atomic.AddInt32(&s.shutdown, 1) != 1 {
		logging.CPrint(logging.INFO, "server is already in the process of shutting down", logging.LogFormat{})
		return nil
	}
	s.syncManager.Stop()
	close(s.quit)
	s.wg.Done()
	return nil
}
Stop gracefully shuts down the server by stopping and disconnecting all
peers and the main listener.
package main
import (
	"path/filepath"
	"sync"
	"sync/atomic"
	"time"
	"github.com/massnetorg/mass-core/blockchain/state"
	chaincfg "github.com/massnetorg/mass-core/config"
	"github.com/massnetorg/mass-core/logging"
	"github.com/massnetorg/mass-core/blockchain"
	"github.com/massnetorg/mass-core/database"
	"github.com/massnetorg/mass-core/netsync"
	"github.com/massnetorg/mass-core/wire"
	"github.com/massnetorg/mass-core/consensus"
)
type server struct {
	started     int32  
	shutdown    int32  
	db          database.Db
	chain       *blockchain.Blockchain
	syncManager *netsync.SyncManager
	wg          sync.WaitGroup
	quit        chan struct{}
}
func (s *server) Start() {
	if atomic.AddInt32(&s.started, 1) != 1 {
		logging.CPrint(logging.INFO, "started exit", logging.LogFormat{"started": s.started})
		return
	}
	logging.CPrint(logging.TRACE, "starting server", logging.LogFormat{})
	logging.CPrint(logging.INFO, "begin to start any com", logging.LogFormat{})
	s.syncManager.Start()
	s.wg.Add(1)
}