- Created config.go with Config struct - Created daemon.go with Daemon struct and Start/Stop methods - Created logger.go for logging setup - Created process.go for lock/PID management - Created fingerprint.go for database validation - Created flock_unix.go/flock_windows.go for platform-specific locking - Created git.go for git operations Still TODO: - Implement runGlobalDaemon, startRPCServer, runSyncLoop - Create sync.go, rpc.go, jsonl.go, validation.go - Update cmd/bd/daemon.go to use daemonrunner Part of bd-5f26
19 lines
324 B
Go
19 lines
324 B
Go
//go:build unix
|
|
|
|
package daemonrunner
|
|
|
|
import (
|
|
"os"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
// flockExclusive acquires an exclusive non-blocking lock on the file
|
|
func flockExclusive(f *os.File) error {
|
|
err := unix.Flock(int(f.Fd()), unix.LOCK_EX|unix.LOCK_NB)
|
|
if err == unix.EWOULDBLOCK {
|
|
return ErrDaemonLocked
|
|
}
|
|
return err
|
|
}
|