Catching error when PIDfile cannot be deleted

Usually the PIDfile is locate in /run. If Salt is not started with root
permissions, it is not able to delete the PIDfile in /run. It should
be safe to just log and ignore this error, since Salt overwrites the
PIDfile on the next start.
This commit is contained in:
Jochen Breuer 2017-09-06 10:16:51 +02:00
parent 0c986f5eba
commit daf4948b3d
No known key found for this signature in database
GPG key ID: 29ACE79F4D5EEE69

View file

@ -882,7 +882,14 @@ class DaemonMixIn(six.with_metaclass(MixInMeta, object)):
# We've loaded and merged options into the configuration, it's safe
# to query about the pidfile
if self.check_pidfile():
os.unlink(self.config['pidfile'])
try:
os.unlink(self.config['pidfile'])
except OSError as err:
self.info(
'PIDfile could not be deleted: {0}'.format(
self.config['pidfile'], traceback.format_exc(err)
)
)
def set_pidfile(self):
from salt.utils.process import set_pidfile