Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log output from cron jobs. #2826

Merged
merged 2 commits into from Mar 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,9 @@ language: python
python:
- "2.7"
env:
- PIP_DOWNLOAD_CACHE="pip_cache"
global:
- PIP_DOWNLOAD_CACHE="pip_cache"
- CRON_LOG_DIR="/tmp/bedrock-cron-log"
branches:
only:
- master
Expand Down
11 changes: 11 additions & 0 deletions bin/gen-crons.py
Expand Up @@ -7,6 +7,7 @@

HEADER = '!!AUTO-GENERATED!! Edit {template}.tmpl instead.'
TEMPLATE_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'etc', 'cron.d'))
LOG_DIR = os.getenv('CRON_LOG_DIR', '/var/log/bedrock')


def main():
Expand All @@ -31,9 +32,18 @@ def main():
if not opts.template:
parser.error('-t must be defined')

# ensure log path exists
if not os.path.isdir(LOG_DIR):
try:
os.mkdir(LOG_DIR)
except OSError:
parser.error('failed to create log directory: ' + LOG_DIR)

log_file = 'cron-{0}.log'.format(opts.template.split('-')[1])
django_manage = 'cd {{dir}} && {py} manage.py'.format(py=opts.python)
django_cron = '{0} cron'.format(django_manage)
ctx = {
'log': '>> {0}/{1}.log 2>&1'.format(LOG_DIR, log_file),
'django_manage': django_manage.format(dir=opts.webapp),
'django_src_manage': django_manage.format(dir=opts.source),
'django_cron': django_cron.format(dir=opts.webapp),
Expand Down Expand Up @@ -62,5 +72,6 @@ def main():
# atomically move into place
os.rename(tmpl_temp_name, tmpl_final_name)


if __name__ == '__main__':
main()
15 changes: 9 additions & 6 deletions etc/cron.d/bedrock-dev.tmpl
Expand Up @@ -4,15 +4,18 @@

MAILTO="webops-cron@mozilla.com,cron-bedrock@mozilla.com"

*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-php.sh
*/20 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-django.sh
*/15 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-locale.sh
# add date/time info to cron log
0 * * * * {{ user }} date {{ log }}

*/5 * * * * {{ django_manage }} rnasync > /dev/null 2>&1
*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-php.sh {{ log }}
*/20 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-django.sh {{ log }}
*/15 * * * * {{ user }} {{ source }}/bin/update-scripts/dev/update-dev-locale.sh {{ log }}

*/5 * * * * {{ django_manage }} rnasync {{ log }}

# bug 1014586
3 */2 * * * {{ django_cron }} update_tweets > /dev/null 2>&1
3 */2 * * * {{ django_cron }} update_tweets {{ log }}

# bug 1128587
38 * * * * {{ django_manage }} runscript update_firefox_os_feeds > /dev/null 2>&1
38 * * * * {{ django_manage }} runscript update_firefox_os_feeds {{ log }}

19 changes: 11 additions & 8 deletions etc/cron.d/bedrock-prod.tmpl
Expand Up @@ -4,25 +4,28 @@

MAILTO="webops-cron@mozilla.com,cron-bedrock@mozilla.com"

*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/prod/update-prod-php.sh
*/15 * * * * {{ user }} {{ source }}/bin/update-scripts/prod/update-prod-locale-cron.sh
# add date/time info to cron log
0 * * * * {{ user }} date {{ log }}

*/5 * * * * {{ django_manage }} rnasync > /dev/null 2>&1
*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/prod/update-prod-php.sh {{ log }}
*/15 * * * * {{ user }} {{ source }}/bin/update-scripts/prod/update-prod-locale-cron.sh {{ log }}

*/5 * * * * {{ django_manage }} rnasync {{ log }}

# bug 996144 & 1014586
2 */6 * * * {{ django_cron }} update_tweets > /dev/null 2>&1
2 */6 * * * {{ django_cron }} update_tweets {{ log }}

# bug 1072999, 1109344
# Have to do this in the SRC dir because rsync destroys git repos in WWW dir.
*/30 * * * * {{ django_src_manage }} update_security_advisories --quiet > /dev/null
*/30 * * * * {{ django_src_manage }} update_security_advisories --quiet {{ log }}

# bug 1087533
42 * * * * {{ django_cron }} update_reps_ical > /dev/null 2>&1
42 * * * * {{ django_cron }} update_reps_ical {{ log }}

# bug 1128587
38 * * * * {{ django_manage }} runscript update_firefox_os_feeds > /dev/null 2>&1
38 * * * * {{ django_manage }} runscript update_firefox_os_feeds {{ log }}

# bug 1116511
# every tuesday midnight
0 0 * * 2 {{ django_manage }} runscript update_tableau_data
0 0 * * 2 {{ django_manage }} runscript update_tableau_data {{ log }}

19 changes: 11 additions & 8 deletions etc/cron.d/bedrock-stage.tmpl
Expand Up @@ -4,25 +4,28 @@

MAILTO="webops-cron@mozilla.com,cron-bedrock@mozilla.com"

*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/stage/update-stage-php.sh
*/15 * * * * {{ user }} {{ source }}/bin/update-scripts/stage/update-stage-locale.sh
# add date/time info to cron log
0 * * * * {{ user }} date {{ log }}

*/5 * * * * {{ django_manage }} rnasync > /dev/null 2>&1
*/10 * * * * {{ user }} {{ source }}/bin/update-scripts/stage/update-stage-php.sh {{ log }}
*/15 * * * * {{ user }} {{ source }}/bin/update-scripts/stage/update-stage-locale.sh {{ log }}

*/5 * * * * {{ django_manage }} rnasync {{ log }}

# bug 996144
1 */2 * * * {{ django_cron }} update_tweets > /dev/null 2>&1
1 */2 * * * {{ django_cron }} update_tweets {{ log }}

# bug 1072999
# Have to do this in the SRC dir because rsync destroys git repos in WWW dir.
41 * * * * {{ django_src_manage }} update_security_advisories --quiet
41 * * * * {{ django_src_manage }} update_security_advisories --quiet {{ log }}

# bug 1087533
42 * * * * {{ django_cron }} update_reps_ical > /dev/null 2>&1
42 * * * * {{ django_cron }} update_reps_ical {{ log }}

# bug 1128587
38 * * * * {{ django_manage }} runscript update_firefox_os_feeds > /dev/null 2>&1
38 * * * * {{ django_manage }} runscript update_firefox_os_feeds {{ log }}

# bug 1116511
# every tuesday midnight
0 0 * * 2 {{ django_manage }} runscript update_tableau_data
0 0 * * 2 {{ django_manage }} runscript update_tableau_data {{ log }}