增加log日志,关机的锁

This commit is contained in:
wangsong 2021-12-02 13:54:32 +08:00
parent 5e1d9d36be
commit 993511903f
1 changed files with 7 additions and 4 deletions

View File

@ -739,9 +739,10 @@ def LockedPreventShutdown():
try:
if not locked:
fcntl.flock(pidfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
logging.info("Has been locked.")
logging.info("Shutdown Has been locked...")
locked = True
except:
except Exception as e:
logging.error(str(e))
locked = False
logging.error("file cannot be locked.")
return False
@ -751,13 +752,15 @@ def unLockedEnableShutdown():
global pidfile
global locked
if not pidfile:
logging.errr("pidfile file disc is None...")
return False
try:
fcntl.flock(pidfile, fcntl.LOCK_UN)
pidfile.close()
locked = False
logging.info("Has been unlocked.")
except:
logging.info("Shutdown Has been unlocked...")
except Exception as e:
logging.error(str(e))
logging.error("unlock failed.")
return False