From a7ed6abf40f1dab6a0fede3c6e0c43cadcaaa9e4 Mon Sep 17 00:00:00 2001 From: Massimo Di Pierro Date: Sun, 4 Dec 2011 16:01:15 -0600 Subject: [PATCH] http://code.google.com/p/web2py/issues/detail?id=548 --- VERSION | 2 +- gluon/newcron.py | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/VERSION b/VERSION index dea84695..87b13f35 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -Version 1.99.3 (2011-12-04 15:48:02) dev +Version 1.99.3 (2011-12-04 16:01:11) dev diff --git a/gluon/newcron.py b/gluon/newcron.py index 2c7b91bc..08187dd6 100644 --- a/gluon/newcron.py +++ b/gluon/newcron.py @@ -23,6 +23,19 @@ from settings import global_settings logger = logging.getLogger("web2py.cron") _cron_stopping = False +def absolute_path_link(path): + """ + Return an absolute path for the destination of a symlink + + """ + if os.path.islink(path): + link = os.readlink(path) + if not os.path.isabs(link): + link = os.path.join(os.path.dirname(path), link) + else: + link = os.path.abspath(path) + return link + def stopcron(): "graceful shutdown of cron" global _cron_stopping @@ -244,10 +257,20 @@ def crondance(applications_parent, ctype='soft', startup=False): apps = [x for x in os.listdir(apppath) if os.path.isdir(os.path.join(apppath, x))] + full_apath_links = set() + for app in apps: if _cron_stopping: break; apath = os.path.join(apppath,app) + + # if app is a symbolic link to other app, skip it + full_apath_link = absolute_path_link(apath) + if full_apath_link in full_apath_links: + continue + else: + full_apath_links.add(full_apath_link) + cronpath = os.path.join(apath, 'cron') crontab = os.path.join(cronpath, 'crontab') if not os.path.exists(crontab):