def make_pidfile(self):
if not os.path.isdir(PIDFILE_PATH):
os.mkdir(PIDFILE_PATH)
pidfilename = os.path.join(PIDFILE_PATH, "{}.pid".format(self.name))
for fn in os.listdir(PIDFILE_PATH):
if not fn.endswith('.pid') or fn.count('_') != 2:
continue
pid, model, clsname = fn.split('_')
if clsname == self.__class__.__name__ + '.pid' and model == self.model_name:
self.kill_process(fn)
with open(pidfilename, 'w+') as f:
f.write(str(self.process.pid))
os.chmod(pidfilename, stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP | stat.S_IWGRP | stat.S_IROTH | stat.S_IWOTH)
评论列表
文章目录