Hanlen
11/15/2019 - 9:41 AM

create single process instance

package main

import (
	"context"
	"fmt"
	"github.com/marcsauter/single"
	"os"
	"syscall"
	"time"
	"log"
)




func main() {
	s := single.New("updater")
	if err := s.CheckLock(); err != nil && err == single.ErrAlreadyRunning {
		log.Info("another instance of the app is already running, exiting")
	} else if err != nil {
		// Another error occurred, might be worth handling it as well
		log.Warn("failed to acquire exclusive app lock: %v", err)
	}
	defer s.TryUnlock()
}