Refactor duplicate slapgrid handling

Does not uglily raise, just exits and don't log too many useless things
on log.
parent 99624446
...@@ -85,9 +85,6 @@ LOCALE_ENVIRONMENT_REMOVE_LIST = [ ...@@ -85,9 +85,6 @@ LOCALE_ENVIRONMENT_REMOVE_LIST = [
'LC_TIME', 'LC_TIME',
] ]
class AlreadyRunning(Exception):
pass
class SlapPopen(subprocess.Popen): class SlapPopen(subprocess.Popen):
""" """
...@@ -141,7 +138,6 @@ def setRunning(pid_file): ...@@ -141,7 +138,6 @@ def setRunning(pid_file):
logger = logging.getLogger('Slapgrid') logger = logging.getLogger('Slapgrid')
if os.path.exists(pid_file): if os.path.exists(pid_file):
# Pid file is present # Pid file is present
logger.warning('pid file already exists : %s' % (pid_file))
try: try:
pid = int(open(pid_file, 'r').readline()) pid = int(open(pid_file, 'r').readline())
except ValueError: except ValueError:
...@@ -152,8 +148,10 @@ def setRunning(pid_file): ...@@ -152,8 +148,10 @@ def setRunning(pid_file):
process_name = os.path.basename(sys.argv[0]) process_name = os.path.basename(sys.argv[0])
if process_name in open('/proc/%s/cmdline' % pid, 'r').readline(): if process_name in open('/proc/%s/cmdline' % pid, 'r').readline():
# In case process is present, ignore. # In case process is present, ignore.
raise AlreadyRunning('A slapgrid process is running with pid %s' % pid) logger.warning('New slapos process started, but another slapgrid '
logger.info('Pid file %r was stale one, overwritten' % pid_file) 'process is aleady running with pid %s, exiting.' % pid)
sys.exit(10)
logger.info('Existing pid file %r was stale one, overwritten' % pid_file)
# Start new process # Start new process
write_pid(pid_file) write_pid(pid_file)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment