func (s *Server) Close() {
	if !s.running {
		return
	}
	s.api.Close()
	s.tl.Stop()
	s.manager.Close()
	s.lockFile.Close()
	s.running = false
}
Close will shut down and cleanup the socket
package daemon
import (
	log "github.com/DataDrake/waterlog"
	"github.com/coreos/go-systemd/daemon"
	"github.com/getsolus/ferryd/api"
	"github.com/getsolus/ferryd/config"
	"github.com/getsolus/ferryd/jobs"
	"github.com/getsolus/ferryd/manager"
	"os"
	"os/signal"
	"syscall"
)
type Server struct {
	api     *v1.Listener       
	manager *manager.Manager   
	tl      *manager.Listener  
	lockFile *LockFile
	running  bool
}
func NewServer() *Server {
	return &Server{
		lockFile: NewLockFile(config.Current.LockFile),
	}
}
func (s *Server) killHandler() {
	ch := make(chan os.Signal, 1)
	signal.Notify(ch, os.Interrupt, syscall.SIGTERM)
	go func() {
		<-ch
		log.Infoln("ferryd shutting down")
		s.Close()
		os.Exit(1)
	}()
}
func (s *Server) Bind() error {
	if e := s.lockFile.Lock(); e != nil {
		return e
	}
	store, e := jobs.NewStore()
	if e != nil {
		return e
	}
	s.manager = manager.NewManager(store)
	tl, err := manager.NewListener(config.Current.TransitPath(), s.manager)
	if err != nil {
		return err
	}
	s.tl = tl
	api, err := v1.NewListener(store, s.manager)
	if err != nil {
		return err
	}
	s.api = api
	return s.api.Bind()
}
func (s *Server) Serve() error {
	s.running = true
	s.killHandler()
	s.tl.Start()
	if s.api.SystemdEnabled {
		ok, err := daemon.SdNotify(false, daemon.SdNotifyReady)
		if err != nil {
			log.Errorf("Failed to notify systemd, reason: '%s'\n", err.Error())
			return err
		}
		if !ok {
			log.Warnln("SdNotify failed due to missing environment variable")
		} else {
			log.Goodln("SdNotify successful")
		}
	}
	return s.api.Start()
}