This commit is contained in:
Liang Ding 2022-12-20 19:40:01 +08:00
parent fbfbe1b0ce
commit 1715b150a2
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
3 changed files with 57 additions and 50 deletions

View file

@ -446,10 +446,16 @@ func GetDataAssetsAbsPath() (ret string) {
func tryLockWorkspace() {
WorkspaceLock = flock.New(filepath.Join(WorkspaceDir, ".lock"))
if err := WorkspaceLock.Lock(); nil != err {
logging.LogErrorf("lock workspace [%s] failed: %s", WorkspaceDir, err)
os.Exit(ExitCodeWorkspaceLocked)
ok, err := WorkspaceLock.TryLock()
if ok {
return
}
if nil != err {
logging.LogErrorf("lock workspace [%s] failed: %s", WorkspaceDir, err)
} else {
logging.LogErrorf("lock workspace [%s] failed", WorkspaceDir)
}
os.Exit(ExitCodeWorkspaceLocked)
}
func UnlockWorkspace() {