Browse Source

Merge 4593feda3d into 116419129e

pull/114/merge
Ronald Ip 8 years ago
committed by GitHub
parent
commit
c390bcb1ea
10 changed files with 198 additions and 7 deletions
  1. +1
    -0
      Procfile
  2. +14
    -0
      README.md
  3. +34
    -0
      app.json
  4. +36
    -0
      bin/post_compile
  5. +15
    -0
      bin/run_compress
  6. +57
    -0
      hc/heroku_settings.py
  7. +2
    -0
      hc/settings.py
  8. +3
    -2
      hc/wsgi.py
  9. +9
    -0
      requirements.in
  10. +27
    -5
      requirements.txt

+ 1
- 0
Procfile View File

@ -0,0 +1 @@
web: gunicorn hc.wsgi --log-file -

+ 14
- 0
README.md View File

@ -22,6 +22,20 @@ The building blocks are:
* Django 1.9
* PostgreSQL or MySQL
## Deploying to Heroku
[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy)
Upon successful deploy via the Heroku Button, the [Postgresql](https://elements.heroku.com/addons/heroku-postgresql), [Mailgun](https://elements.heroku.com/addons/mailgun), and [Scheduler](https://elements.heroku.com/addons/scheduler) add-ons will be provisioned and configured for use. The initial database migration task will also be run.
The site should now be running at `https://appname.herokuapp.com/`.
### Heroku Configuration
1. Create a superuser manually: `$ heroku run python manage.py createsuperuser --app <appname>`.
2. Refer to [Sending Status Notifications](#sending-status-notifications) and [Database Cleanup](#database-cleanup) sections for tasks that are required to be scheduled via [Heroku's Scheduler add-on](https://devcenter.heroku.com/articles/scheduler#scheduling-jobs): `$ heroku addons:open scheduler`.
## Setting Up for Development
These are instructions for setting up HealthChecks Django app


+ 34
- 0
app.json View File

@ -0,0 +1,34 @@
{
"name": "healthchecks",
"website": "https://github.com/healthchecks/healthchecks",
"keywords": ["heroku", "cron", "devops", "python", "monitoring", "cron-jobs"],
"image": "heroku/python",
"addons": [
"heroku-postgresql:hobby-dev",
"mailgun:starter",
"scheduler:standard"
],
"scripts": {
"postdeploy": "python manage.py migrate"
},
"env": {
"SITE_ROOT": {
"description": "Used to build fully qualified URLs for pings, and for use in emails and notifications. Enter your App Name defined above here.",
"value": "https://appname.herokuapp.com/"
},
"SITE_NAME": {
"description": "Used throughout the templates.",
"value": "My Monitoring Project"
},
"FROM_EMAIL": {
"description": "Email from address.",
"value": "[email protected]"
},
"SECRET_KEY": {
"generator": "secret"
},
"ON_HEROKU": {
"value": "yes"
}
}
}

+ 36
- 0
bin/post_compile View File

@ -0,0 +1,36 @@
#!/usr/bin/env bash
set -eo pipefail
# The post_compile hook is run by heroku-buildpack-python
echo "-----> I'm post-compile hook"
# Work around Heroku bug whereby pylibmc isn't available during
# compile phase. See: https://github.com/heroku/heroku-buildpack-python/issues/57
export MEMCACHE_SERVERS='' MEMCACHIER_SERVERS=''
if [ -f bin/install_nodejs ]; then
echo "-----> Running install_nodejs"
chmod +x bin/install_nodejs
bin/install_nodejs
if [ -f bin/install_less ]; then
echo "-----> Running install_lessc"
chmod +x bin/install_less
bin/install_less
fi
fi
if [ -f bin/run_collectstatic ]; then
echo "-----> Running run_collectstatic"
chmod +x bin/run_collectstatic
bin/run_collectstatic
fi
if [ -f bin/run_compress ]; then
echo "-----> Running run_compress"
chmod +x bin/run_compress
bin/run_compress
fi
echo "-----> Post-compile done"

+ 15
- 0
bin/run_compress View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
set -eo pipefail
indent() {
RE="s/^/ /"
[ $(uname) == "Darwin" ] && sed -l "$RE" || sed -u "$RE"
}
MANAGE_FILE=$(find . -maxdepth 3 -type f -name 'manage.py' | head -1)
MANAGE_FILE=${MANAGE_FILE:2}
echo "-----> Compressing static files"
python $MANAGE_FILE compress 2>&1 | indent
echo

+ 57
- 0
hc/heroku_settings.py View File

@ -0,0 +1,57 @@
import os
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SITE_ROOT = os.getenv('SITE_ROOT', "https://my-monitoring-project.com")
SITE_NAME = os.getenv('SITE_NAME', "My Monitoring Project")
DEFAULT_FROM_EMAIL = os.getenv('FROM_EMAIL', "[email protected]")
import herokuify
from herokuify.common import *
from herokuify.mail.mailgun import *
DATABASES = herokuify.get_db_config()
DEBUG = False
SECRET_KEY = os.getenv('SECRET_KEY', "---")
# Allow all host headers
ALLOWED_HOSTS = ['*']
# Simplified static file serving.
# https://warehouse.python.org/project/whitenoise/
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
import sys
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'formatters': {
'verbose': {
'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s",
'datefmt' : "%d/%b/%Y %H:%M:%S"
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'verbose',
'stream': sys.stdout,
},
},
'loggers': {
'django': {
'handlers':['console'],
'propagate': True,
'level':'DEBUG',
},
'MYAPP': {
'handlers': ['console'],
'level': 'DEBUG',
},
}
}

+ 2
- 0
hc/settings.py View File

@ -159,5 +159,7 @@ TELEGRAM_TOKEN = None
if os.path.exists(os.path.join(BASE_DIR, "hc/local_settings.py")):
from .local_settings import *
elif ('ON_HEROKU' in os.environ == 'yes' or 'STACK' in os.environ) and os.path.exists(os.path.join(BASE_DIR, "hc/heroku_settings.py")):
from .heroku_settings import *
else:
warnings.warn("local_settings.py not found, using defaults")

+ 3
- 2
hc/wsgi.py View File

@ -8,9 +8,10 @@ https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hc.settings")
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "hc.settings")
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)

+ 9
- 0
requirements.in View File

@ -0,0 +1,9 @@
croniter
Django
django_compressor
psycopg2
pytz
requests
gunicorn
whitenoise
django-herokuify

+ 27
- 5
requirements.txt View File

@ -1,6 +1,28 @@
croniter
Django==1.10.5
django_compressor==2.1
#
# This file is autogenerated by pip-compile
# To update, run:
#
# pip-compile --output-file requirements.txt requirements.in
#
boto==2.46.1 # via django-herokuify
croniter==0.3.15
dj-database-url==0.4.2 # via django-heroku-postgresify, django-herokuify
django-appconf==1.0.2 # via django-compressor
django-compressor==2.1.1
django-heroku-memcacheify==1.0.0 # via django-herokuify
django-heroku-postgresify==0.4 # via django-herokuify
django-herokuify==1.0rc3
django-pylibmc-sasl==0.2.4 # via django-herokuify
django-pylibmc==0.6.1 # via django-heroku-memcacheify
django-storages==1.5.2 # via django-herokuify
Django==1.10.5 # via django-heroku-postgresify, django-pylibmc-sasl
gunicorn==19.6.0
psycopg2==2.6.2
pytz==2016.7
requests==2.9.1
pylibmc==1.5.1 # via django-herokuify, django-pylibmc, django-pylibmc-sasl
python-dateutil==2.6.0 # via croniter
pytz==2016.10
rcssmin==1.0.6 # via django-compressor
requests==2.13.0
rjsmin==1.0.12 # via django-compressor
six==1.10.0 # via python-dateutil
whitenoise==3.3.0

Loading…
Cancel
Save