Skip to content

Commit

Permalink
refactor: extract lockfile check to function
Browse files Browse the repository at this point in the history
  • Loading branch information
natesales committed Sep 2, 2024
1 parent 73ee819 commit 0d7d3d3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/process/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ func parseStatics(all map[string]string, v4 map[string]string, v6 map[string]str
}

// Load loads a configuration file from a YAML file
//
//gocyclo:ignore
func Load(configBlob []byte) (*config.Config, error) {
var c config.Config
c.Init()
Expand Down Expand Up @@ -618,9 +620,8 @@ func peer(peerName string, peerData *config.Peer, c *config.Config, wg *sync.Wai
return nil
}

// Run runs the full data generation procedure
func Run(configFilename, lockFile, version string, noConfigure, dryRun, withdraw bool) {
// Check lockfile
// lock prevents multiple instances of Pathvector from running
func lock(lockFile string) {
if lockFile != "" {
if _, err := os.Stat(lockFile); err == nil {
log.Fatal("Lockfile exists, exiting")
Expand All @@ -635,6 +636,11 @@ func Run(configFilename, lockFile, version string, noConfigure, dryRun, withdraw
log.Fatalf("Accessing lockfile: %v", err)
}
}
}

// Run runs the full data generation procedure
func Run(configFilename, lockFile, version string, noConfigure, dryRun, withdraw bool) {
lock(lockFile)

log.Infof("Starting Pathvector %s", version)
startTime := time.Now()
Expand Down

0 comments on commit 0d7d3d3

Please sign in to comment.