Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Bug 1118786: Prep deployment and crons for Python 2.7
- Loading branch information
Showing
13 changed files
with
175 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
#!/usr/bin/env python | ||
import os | ||
from optparse import OptionParser | ||
|
||
from jinja2 import Template | ||
|
||
|
||
HEADER = '!!AUTO-GENERATED!! Edit {template}.tmpl instead.' | ||
TEMPLATE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'etc', 'cron.d')) | ||
|
||
|
||
def main(): | ||
parser = OptionParser() | ||
parser.add_option('-w', '--webapp', | ||
help='Location of web app (required)') | ||
parser.add_option('-s', '--source', | ||
help='Location of source for the web app (required)') | ||
parser.add_option('-t', '--template', | ||
help='Name of the template (e.g. bedrock-prod)') | ||
parser.add_option('-u', '--user', default='root', | ||
help=('Prefix cron with this user. ' | ||
'Only define for cron.d style crontabs.')) | ||
parser.add_option('-p', '--python', default='python2.6', | ||
help='Python interpreter to use.') | ||
|
||
(opts, args) = parser.parse_args() | ||
|
||
if not opts.webapp: | ||
parser.error('-w must be defined') | ||
|
||
if not opts.template: | ||
parser.error('-t must be defined') | ||
|
||
django_manage = 'cd %s && %s manage.py' % (opts.webapp, opts.python) | ||
ctx = { | ||
'django_manage': django_manage, | ||
'django_cron': '%s cron' % django_manage, | ||
} | ||
|
||
for k, v in ctx.iteritems(): | ||
ctx[k] = '%s %s' % (opts.user, v) | ||
|
||
# Needs to stay below the opts.user injection. | ||
ctx['user'] = opts.user | ||
ctx['webapp'] = opts.webapp | ||
ctx['source'] = opts.source | ||
ctx['python'] = opts.python | ||
ctx['header'] = HEADER.format(template=opts.template) | ||
|
||
tmpl_final_name = os.path.join(TEMPLATE_DIR, opts.template) | ||
tmpl_src_name = tmpl_final_name + '.tmpl' | ||
tmpl_temp_name = tmpl_final_name + '.TEMP' | ||
try: | ||
with open(tmpl_src_name, 'r') as src_fh: | ||
with open(tmpl_temp_name, 'w') as out_fh: | ||
out_fh.write(Template(src_fh.read()).render(**ctx)) | ||
except IOError: | ||
parser.error('file must exist: ' + tmpl_src_name) | ||
|
||
# atomically move into place | ||
os.rename(tmpl_temp_name, tmpl_final_name) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bedrock-* | ||
!bedrock-*.tmpl |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# | ||
# {{ header }} | ||
# | ||
|
||
MAILTO="webops-cron@mozilla.com,cron-bedrock@mozilla.com" | ||
|
||
0-59/10 * * * * root /data/bedrock-dev/src/update-www-dev.allizom.org.sh | ||
1-59/10 * * * * root /data/bedrock-dev/src/update-www-dev.allizom.org-django.sh | ||
0 * * * * {{ django_cron }} update_feeds > /dev/null 2>&1 | ||
*/5 * * * * {{ django_manage }} rnasync > /dev/null 2>&1 | ||
|
||
*/15 * * * * root /data/bedrock-dev/src/update-www-dev.allizom.org-svn-locale.sh | ||
|
||
# bug 1014586 | ||
3 */2 * * * {{ django_cron }} update_tweets > /dev/null 2>&1 | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# | ||
# {{ header }} | ||
# | ||
|
||
MAILTO="webops-cron@mozilla.com,cron-bedrock@mozilla.com" | ||
|
||
*/10 * * * * root /data/bedrock/src/update-www.mozilla.org.sh | ||
|
||
*/5 * * * * {{ django_manage }} rnasync > /dev/null 2>&1 | ||
*/15 * * * * {{ user }} /data/bedrock/src/update-www.mozilla.org-cron-svn-locale.sh &> /dev/null | ||
# outputs when the run completed to http://www.mozilla.org/media/locale_finished.txt | ||
|
||
# disabled per bug 1042074 | ||
#1-59/15 * * * * {{ user }} /data/bedrock/src/update-www.mozilla.org-product-details.sh | ||
|
||
# bug 996144 & 1014586 | ||
2 */6 * * * {{ django_cron }} update_tweets > /dev/null 2>&1 | ||
|
||
# bug 1072999, 1109344 | ||
*/30 * * * * {{ django_manage }} update_security_advisories --quiet > /dev/null 2>&1 | ||
|
||
# bug 1087533 | ||
42 * * * * {{ django_cron }} update_reps_ical > /dev/null 2>&1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters