Commit 2a85e9bb authored by Łukasz Nowak's avatar Łukasz Nowak

cli: Check pid file before random_delay

If there is another process running now, there is no need to wait, especially
without pidfile, so create such file immediately, then wait if needed.
parent 157d0c09
Pipeline #9021 failed with stage
in 0 seconds
...@@ -104,10 +104,6 @@ class SlapgridCommand(ConfigCommand): ...@@ -104,10 +104,6 @@ class SlapgridCommand(ConfigCommand):
check_missing_parameters(options) check_missing_parameters(options)
check_missing_files(options) check_missing_files(options)
random_delay(options, logger=self.app.log)
slapgrid_object = create_slapgrid_object(options, logger=self.app.log)
pidfile = ( options.get(self.pidfile_option_name) or pidfile = ( options.get(self.pidfile_option_name) or
options.get('pidfile') or # for compatibility we also read pidfile from option `pidfile` options.get('pidfile') or # for compatibility we also read pidfile from option `pidfile`
self.default_pidfile ) self.default_pidfile )
...@@ -115,6 +111,8 @@ class SlapgridCommand(ConfigCommand): ...@@ -115,6 +111,8 @@ class SlapgridCommand(ConfigCommand):
if pidfile: if pidfile:
setRunning(logger=self.app.log, pidfile=pidfile) setRunning(logger=self.app.log, pidfile=pidfile)
try: try:
random_delay(options, logger=self.app.log)
slapgrid_object = create_slapgrid_object(options, logger=self.app.log)
return getattr(slapgrid_object, self.method_name)() return getattr(slapgrid_object, self.method_name)()
finally: finally:
if pidfile: if pidfile:
......
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