Commit 8d2959f6 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Fix clean cron def

parent 9aada461
...@@ -34,6 +34,14 @@ class Crons: ...@@ -34,6 +34,14 @@ class Crons:
self.init_clean_cron() self.init_clean_cron()
self.init_launch_local_cron() self.init_launch_local_cron()
@staticmethod
def _get_python_exec():
pyexec = sys.executable
match = re.match(r"^(.+)/lib/(python[^/]+)/((site-packages/bin/python)|())$", pyexec)
if match:
pyexec = "%s/bin/%s" % (match.group(1), match.group(2))
return pyexec
def init_clean_cron(self): def init_clean_cron(self):
""" """
Clean cron is launched at 1h00am each day Clean cron is launched at 1h00am each day
...@@ -41,8 +49,9 @@ class Crons: ...@@ -41,8 +49,9 @@ class Crons:
clean_time = self.config.cron_clean_time clean_time = self.config.cron_clean_time
clean_freq = self.config.cron_clean_freq clean_freq = self.config.cron_clean_freq
if self.base_dir is not None: if self.base_dir is not None:
job = self.my_cron.new(sys.executable + job = self.my_cron.new(self._get_python_exec() +
" {0}/bin/clean_jobs.py > {0}/clean.log 2>&1".format(self.config.log_dir), " {0}/bin/clean_jobs.py > {1}/clean.log 2>&1".format(self.base_dir,
self.config.log_dir),
comment="dgenies") comment="dgenies")
job.day.every(clean_freq) job.day.every(clean_freq)
job.hour.on(clean_time[0]) job.hour.on(clean_time[0])
...@@ -57,10 +66,7 @@ class Crons: ...@@ -57,10 +66,7 @@ class Crons:
:return: :return:
""" """
if self.base_dir is not None: if self.base_dir is not None:
pyexec = sys.executable pyexec = self._get_python_exec()
match = re.match(r"^(.+)/lib/(python[^/]+)/((site-packages/bin/python)|())$", pyexec)
if match:
pyexec = "%s/bin/%s" % (match.group(1), match.group(2))
logs = os.path.join(self.config.log_dir, "local_scheduler.log") if self.debug else "/dev/null" logs = os.path.join(self.config.log_dir, "local_scheduler.log") if self.debug else "/dev/null"
job = self.my_cron.new("{0}/bin/start_local_scheduler.sh {0} {1} {2} {3} > /dev/null 2>&1 &". job = self.my_cron.new("{0}/bin/start_local_scheduler.sh {0} {1} {2} {3} > /dev/null 2>&1 &".
format(self.base_dir, pyexec, self.local_scheduler_pid_file, logs), format(self.base_dir, pyexec, self.local_scheduler_pid_file, logs),
......
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