mirror of
https://github.com/mudler/luet.git
synced 2025-09-16 07:10:29 +00:00
Make possible to disable app locking
This commit is contained in:
18
cmd/root.go
18
cmd/root.go
@@ -43,15 +43,17 @@ var RootCmd = &cobra.Command{
|
||||
// Execute adds all child commands to the root command sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
s := single.New("luet")
|
||||
if err := s.CheckLock(); err != nil && err == single.ErrAlreadyRunning {
|
||||
Fatal("another instance of the app is already running, exiting")
|
||||
} else if err != nil {
|
||||
// Another error occurred, might be worth handling it as well
|
||||
Fatal("failed to acquire exclusive app lock:", err.Error())
|
||||
// XXX: This is mostly from scratch images.
|
||||
if os.Getenv("LUET_NOLOCK") != "true" {
|
||||
s := single.New("luet")
|
||||
if err := s.CheckLock(); err != nil && err == single.ErrAlreadyRunning {
|
||||
Fatal("another instance of the app is already running, exiting")
|
||||
} else if err != nil {
|
||||
// Another error occurred, might be worth handling it as well
|
||||
Fatal("failed to acquire exclusive app lock:", err.Error())
|
||||
}
|
||||
defer s.TryUnlock()
|
||||
}
|
||||
defer s.TryUnlock()
|
||||
|
||||
if err := RootCmd.Execute(); err != nil {
|
||||
Error(err)
|
||||
os.Exit(-1)
|
||||
|
Reference in New Issue
Block a user