Skip to content
This repository was archived by the owner on Jun 2, 2019. It is now read-only.

Commit ebb8285

Browse files
committedNov 2, 2018
fix HealthCheck log filtering
1 parent ce8f97f commit ebb8285

File tree

7 files changed

+320
-109
lines changed

7 files changed

+320
-109
lines changed
 

‎.travis.yml

+3-10
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,18 @@ env:
1111
- secure: iJv9zwNPA6EeLgTUhiaTq3YnoSPILqz5Oerl1XoAbL6F5kcXrtY1/mw8BnqdgM7QIr7Q6fi75L1Ts2jBsi0IU/4FtlhRKuaMqlmCBd8z52Mb+KEGP3YJhfPceq5raVqIjc5nHikd2CsGdtSr6gFfNaRITvHqwaUs8owF5eMQX6irxnnWVmz47mKwxZ251vGQGyEukAYQRcIwzjr2dnA94E+tj2pTaCXJO4sBc9BqeDO+rYQCWc1yivhHxx0Zr/JuR/jceNjNL2rZa41GmHMlHenFcnseH84OQ/+/c7AmPLHcYmiTJIL1yY+sMS/PRhLOGzQnxIQvaA1LD8gEAY+YLn3Q6AgHveV28udfU7jzKQmgRqS4OeM1OhykknBcAdLo8k2gbVx73pO32Lgse0JL2S2jmr/yWBpYGoXJ/LeB4x+YG5mookGktRbwtb/RyPI/+W4DE8mgD/d5b0u6zXCwIQ1Xe78Lr4k+uo3mWMnjcvix2gLkPDwlW4zZ8UGe7M9XCkKuZnhxGUV3ijBuecIMBfABi1wGstXQzHLNtiul0ZPWUAeQxDoN+lr94aw+R0U9DcTHWtM2QXY77+olV7D9pnbPZKXB2QRfOpvS2jDQo4nXGCVV/UmCrYgC9sDQQD5u8QXqgJRHTb7Rl+9AKwl1C5u60sBRRpaneQlRBLOjWlo=
1212
- secure: MZlr2GanK4Je41ncRFHwJm8SyJ1yjPI3gKFdXb5xoVMdsKBnYbouz+5PG73Ri9oDnOYsY6c9lv6HrSSo6fO0fc/lyhZeKu34F288rAYPGJdg/Qn0c0xYsKug2qPAn+Oyl0BWjnfR5nSP7cdhRVwca84kVVfOWer6DP+bZZ2tJda5xKqyRFgvZRWZnrUegY/ciXtwjLswnwOX9VE9x0un29acsZvWDCRoGFM0P6SeM/aVYp+o5iJyw6mD8wtmLcw4kI6q3r6S2MbGJ+fefiUW70Of3oUD721aW2DYVkMd5pRgW3/VvW5km+UNo8zD9pffZLGev68hdyEA0Rhrw/qX5DinoS46HnSVlyJWdDUselYELumHAKdIjuWYMaW0sboN89mfNX0H1KaXT2Gc1+eO6nlmJLKwK2KQYULgQXkKoOOhCvvvw+uhMaqxjMp+oLcvwHt6s96KjlRGn7dNDnDePpWH7Pht0L1cYg9xnaeTKJfQm2N6cOQtLKHO/rBHYiEItG6O/kaQytokrU1tLo6Y5o3+8dybvulFha3xgq39oI0Mtp5fVbMM3wZOLQ5UqedYATMaoy4LamEiP0cvThlP5X5/TvyFcQxBu39EYWmaBcSPooncQVPoGyLzVAcfBQp3hOe0XbYKoY0VjHVWYbO2ghVXVax8CDJZ2feE5ghsdMQ=
1313

14-
sudo: required
15-
1614
os: linux
17-
15+
sudo: required
1816
language: python
19-
20-
python: 3.6
21-
17+
dist: xenial
18+
python: 3.7
2219
cache: pip
23-
2420
install:
2521
- pip install pipenv
2622
- pipenv install --system --deploy --dev
27-
2823
script:
2924
- pytest
30-
3125
services:
3226
- docker
33-
3427
after_success:
3528
- bash bin/run.sh

‎Pipfile

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ psycopg2 = "*"
1919
requests = "*"
2020
slack-sansio = "*"
2121
"slack-sansio[requests]" = "*"
22+
pyyaml = "*"
23+
websocket = "*"
2224

2325
[dev-packages]
2426
pytest = "*"
@@ -27,3 +29,6 @@ django-debug-toolbar = "*"
2729

2830
[requires]
2931
python_version = "3.7"
32+
33+
[pipenv]
34+
allow_prereleases = true

‎Pipfile.lock

+204-88
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎README.md

+90
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,93 @@
1+
<div align="center">
2+
<br />
3+
<a href="https://operationcode.org">
4+
<img
5+
alt="Operation Code logo"
6+
src="https://s3.amazonaws.com/operationcode-assets/branding/logos/large-blue-logo.png"
7+
width="75%"
8+
>
9+
</a>
10+
<br />
11+
<br />
12+
</div>
13+
14+
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
15+
[![Twitter Follow](https://img.shields.io/twitter/follow/operation_code.svg?style=social&label=Follow&style=social)](https://twitter.com/operation_code)
16+
[![GitHub contributors](https://img.shields.io/github/contributors/cdnjs/cdnjs.svg)](https://github.com/OperationCode/operationcode_backend)
17+
18+
19+
[![Build Status](https://travis-ci.org/OperationCode/operationcode-pyback.svg?branch=master)](https://travis-ci.org/OperationCode/operationcode-pyback)
20+
[![View performance data on Skylight](https://badges.skylight.io/status/0iQU6bEW8ha1.svg)](https://oss.skylight.io/app/applications/0iQU6bEW8ha1)
21+
[![Good First Issue](https://img.shields.io/github/issues/OperationCode/front-end/good%20first%20issue.svg)](https://github.com/OperationCode/operationcode_backend/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)
22+
23+
# Welcome!
24+
25+
This is the back-end application for [OperationCode](https://operationcode.org). We highly recommend [joining our organization](https://operationcode.org/join) to receive an invite to our Slack team. From there, you'll want to join the `#oc-projects` and `#oc-ruby-projects` channels. You can get help from multiple professional developers.
26+
27+
Before contributing, please review our [Contributing Guide](CONTRIBUTING.md)
28+
29+
## Maintainers
30+
31+
For information about the maintainers of the project, check out [MAINTAINERS.md](MAINTAINERS.md).
32+
33+
## Quick Start
34+
If you're unsure of how to start this app or code for it, don't worry! You're our target audience!
35+
Please read our [Contributing Guide](CONTRIBUTING.md) to learn everything you need to be able to ask the right questions on our Slack team.
36+
37+
**In continuing with the quick start instructions, it is assumed that you are no stranger to Rails Applications, and standard GitHub workflows such as forking, cloning, and branching.**
38+
39+
## Description
40+
If you'd like to learn more about what this project is what a Backend is you can read about this in our [Introduction Guide](INTRODUCTION.md).
41+
42+
Recommended versions of tools used within the repo:
43+
44+
* Ruby: See [.ruby-version](https://github.com/OperationCode/operationcode_backend/blob/master/.ruby-version)
45+
* `ruby@2.3.3`
46+
* `git@2.17.0` or greater
47+
48+
49+
<details>
50+
<summary>Expand To View Quickstart</summary>
51+
<ol>
52+
<li> Install Dependencies (git, gnu make, docker) </li>
53+
54+
<ul>
55+
<li> <a href="https://github.com/OperationCode/operationcode_backend/blob/master/docs/setup/docker_setup.md#git">git</a> </li>
56+
<li> <a href="https://github.com/OperationCode/operationcode_backend/blob/master/docs/setup/docker_setup.md#make-for-windows-only">make</a> </li>
57+
<li> <a href="https://github.com/OperationCode/operationcode_backend/blob/master/docs/setup/docker_setup.md#docker">docker</a> </li>
58+
</ul>
59+
60+
<li> <a href="https://github.com/OperationCode/operationcode_backend/blob/master/docs/setup/docker_setup.md#local-development-environment"> Retrieve Codebase</a> </li>
61+
62+
<li> <a href="https://github.com/OperationCode/operationcode_backend/blob/master/docs/setup/docker_setup.md#database-setup"> Retrieve Codebase</a> </li>
63+
<li> <a href="https://github.com/OperationCode/operationcode_backend/blob/master/docs/setup/docker_setup.md#running-operationcode-backend"> Setup Codebase</a> </li>
64+
<li> <a href="https://github.com/OperationCode/operationcode_backend/blob/master/docs/setup/docker_setup.md#interact-with-backend"> Interact with Codebase</a> </li>
65+
66+
</ol>
67+
68+
</details >
69+
70+
## Wiki
71+
72+
We also have a [wiki](https://github.com/OperationCode/operationcode_backend/wiki) that contains common tutorials, tips, workflows and documentation around how to successfully contribute to, and work within, the operationcode_backend repository.
73+
74+
## Postmortem Reports
75+
76+
<details>
77+
78+
<summary>Click to expand </summary>
79+
80+
81+
As incidents happen that require a great deal of troubleshooting and reveal a certain lack of domain knowledge, we wish to document these issues in way that can be used for contributors to learn. When such an event happens and a Root Cause Analysis is performed these issues will be added here.
82+
83+
For the purpose of security we need to ensure that no data is added to AAR that would compromise any operation code asset. These reports are intended to document issues and reasoning for future contributors and assist future investigations. In these reports we keep the details blameless and focus on how we can improve and iterate in a better manner.
84+
85+
<ol>
86+
<li> Slack User invites Stopped <a href="https://github.com/OperationCode/operationcode_backend/issues/388">link</a></li>
87+
</ol>
88+
</details>
89+
90+
191
# [OperationCode-Pyback](https://github.com/OperationCode/operationcode-Pyback)
292

393

‎docker/Dockerfile

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ RUN mkdir /static
1010
COPY Pipfile* /src/
1111

1212
RUN apt-get update \
13-
&& apt-get install -y libpq-dev gcc \
13+
&& apt-get install -y libpq-dev python3-websocket gcc \
1414
&& rm -rf /var/lib/apt/lists/* \
1515
&& pip install --upgrade pip \
1616
&& pip install pipenv \
@@ -20,4 +20,6 @@ RUN apt-get update \
2020
COPY src /src
2121

2222
EXPOSE 8000
23-
CMD python manage.py collectstatic --no-input;python manage.py makemigrations;python manage.py migrate;gunicorn pyback.wsgi -b 0.0.0.0:8000 -w 3 --access-logfile=- --error-logfile=- --capture-output
23+
CMD python manage.py collectstatic --no-input;python manage.py makemigrations;\
24+
python manage.py migrate;\
25+
gunicorn pyback.wsgi -b 0.0.0.0:8000 -w 3 --access-logfile=- --error-logfile=- --capture-output --logger-class "pyback.log.CustomGunicornLogger"

‎src/pyback/log.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
import logging
22

3+
from gunicorn import glogging
4+
35

46
class HealthCheckFilter(logging.Filter):
57
def filter(self, record):
6-
return 'ELB-HealthChecker/2.0' not in record
8+
return 'ELB-HealthChecker' not in record.getMessage()
9+
10+
11+
class CustomGunicornLogger(glogging.Logger):
12+
def setup(self, cfg):
13+
super().setup(cfg)
14+
15+
logger = logging.getLogger('gunicorn.access')
16+
logger.addFilter(HealthCheckFilter())

‎src/pyback/settings.py

+3-8
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,11 @@
99
For the full list of settings and their values, see
1010
https://docs.djangoproject.com/en/2.1/ref/settings/
1111
"""
12-
import logging
13-
14-
from dotenv import load_dotenv
15-
from decouple import config
16-
from pathlib import Path
1712
import os
13+
from pathlib import Path
1814

19-
from .log import HealthCheckFilter
15+
from decouple import config
16+
from dotenv import load_dotenv
2017

2118
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
2219

@@ -178,5 +175,3 @@
178175

179176
if DEBUG:
180177
INTERNAL_IPS = ['127.0.0.1']
181-
182-
logging.getLogger().addFilter(HealthCheckFilter())

0 commit comments

Comments
 (0)
This repository has been archived.