moved the lockfile definition out to snappy.dirs

This commit is contained in:
John R. Lenton
2015-10-29 18:10:49 +00:00
parent 0579a83f18
commit 9c947a8164
2 changed files with 4 additions and 3 deletions
+2 -3
View File
@@ -25,6 +25,7 @@ import (
"strings"
"time"
"github.com/ubuntu-core/snappy/dirs"
"github.com/ubuntu-core/snappy/i18n"
"github.com/ubuntu-core/snappy/logger"
"github.com/ubuntu-core/snappy/priv"
@@ -32,8 +33,6 @@ import (
"github.com/jessevdk/go-flags"
)
const snappyLockFile = "/run/snappy.lock"
func isAutoPilotRunning() bool {
unitName := "snappy-autopilot"
bs, err := exec.Command("systemctl", "show", "--property=SubState", unitName).CombinedOutput()
@@ -48,7 +47,7 @@ func isAutoPilotRunning() bool {
// automatic re-try and helpful messages if the lock is already taken
func withMutexAndRetry(f func() error) error {
for {
err := priv.WithMutex(snappyLockFile, f)
err := priv.WithMutex(dirs.SnapLockFile, f)
// if already locked, auto-retry
if err == priv.ErrAlreadyLocked {
var msg string
+2
View File
@@ -35,6 +35,7 @@ var (
LocaleDir string
SnapIconsDir string
SnapMetaDir string
SnapLockFile string
SnapBinariesDir string
SnapServicesDir string
@@ -59,6 +60,7 @@ func SetRootDir(rootdir string) {
SnapSeccompDir = filepath.Join(rootdir, SnappyDir, "seccomp", "profiles")
SnapIconsDir = filepath.Join(rootdir, SnappyDir, "icons")
SnapMetaDir = filepath.Join(rootdir, SnappyDir, "meta")
SnapLockFile = filepath.Join(rootdir, "/run/snappy.lock")
SnapBinariesDir = filepath.Join(SnapAppsDir, "bin")
SnapServicesDir = filepath.Join(rootdir, "/etc/systemd/system")