Massimo Di Pierro
2011-12-04 16:01:15 -06:00
parent 079dde8835
commit a7ed6abf40
2 changed files with 24 additions and 1 deletions
+1 -1
View File
@@ -1 +1 @@
Version 1.99.3 (2011-12-04 15:48:02) dev
Version 1.99.3 (2011-12-04 16:01:11) dev
+23
View File
@@ -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):