Skip to content

Instantly share code, notes, and snippets.

```
django_1 | Traceback (most recent call last):
django_1 | File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 135, in handle
django_1 | self.handle_request(listener, req, client, addr)
django_1 | File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 176, in handle_request
django_1 | respiter = self.wsgi(environ, resp.start_response)
django_1 | File "/usr/local/lib/python3.6/site-packages/newrelic/api/wsgi_application.py", line 667, in _nr_wsgi_application_wrapper_
django_1 | result = wrapped(environ, _start_response)
django_1 | File "/usr/local/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 141, in __call__
django_1 | response = self.get_response(request)
@lgvital
lgvital / ECS production.yml deploy script
Created August 14, 2019 05:08
1. Set $ECS_CLUSTER variable. 2. Add this to wherever production.yml is located. 3. python deploy.py
import yaml
import subprocess
def main():
subprocess.run(['docker-compose', '-f', 'production.yml', 'build'])
with open("production.yml", 'r') as stream:
try:
prod_yaml = yaml.safe_load(stream)
for service in prod_yaml.get('services').values():
image = service['image']
services:
django:
command: /start
links:
- postgres
env_file:
- ./.envs/.production/.django
- ./.envs/.production/.postgres
build:
context: .
@lgvital
lgvital / gist:7eec445b48bbcca1a2375c03a5dc0c00
Created August 14, 2019 04:43
traefik.toml - django http only
logLevel = "INFO"
defaultEntryPoints = ["http"]
# Entrypoints, http and https
[entryPoints]
[entryPoints.http]
address = ":80"
[file]
[backends]
lionel@machine:~/code/cookiecutter_aws (convert-compose)$ ecs-cli compose --file production.yml service up
WARN[0000] Skipping unsupported YAML option for service... option name=build service name=django
WARN[0000] Skipping unsupported YAML option for service... option name=depends_on service name=django
WARN[0000] Skipping unsupported YAML option for service... option name=build service name=postgres
WARN[0000] Skipping unsupported YAML option for service... option name=depends_on service name=traefik
ERRO[0001] Error registering task definition error="ClientException: containerPath values aren't unique across mountPoints.\n\tstatus code: 400, request id: 425f2d91-c69a-443d-bd17-3f8792249284" family=cookiecutter_aws
ERRO[0001] Create task definition failed error="ClientException: containerPath values aren't unique across mountPoints.\n\tstatus code: 400, request id: 425f2d91-c69a-443d-bd17-3f8792249284"
FATA[0001] ClientException: containerPath values aren't unique across moun
lionel@machine:~/code/cookiecutter_aws (convert-compose)$ ecs-cli up --instance-role cookiecutter -f
WARN[0000] You will not be able to SSH into your EC2 instances without a key pair.
INFO[0001] Defaulting instance type to t2.micro
INFO[0002] Using recommended Amazon Linux 2 AMI with ECS Agent 1.29.1 and Docker version 18.06.1-ce
INFO[0002] Created cluster cluster=cookiecutter region=us-east-1
INFO[0002] Waiting for your CloudFormation stack resources to be deleted...
INFO[0003] Cloudformation stack status stackStatus=DELETE_IN_PROGRESS
ERRO[0033] Error deleting cloudformation stack eventStatus=DELETE_FAILED reason="The following resource(s) failed to delete: [EcsInstanceProfile]. " resource="arn:aws:cloudformation:us-east-1:727419036083:stack/amazon-ecs-cli-setup-cookiecutter/74d4d800-bcd6-11e9-9d59-0a1fbafbd996"
FATA[0033] Error executing 'up': Cloudformation failure waiting for 'DELETE_COMPLETE'. Reason: 'The following resource(s) failed
lionel@machine:~/code/cookiecutter_aws (master)$ python convert-docker-compose-to-aws.py
DOCKERHUB_USER=lionelv
Input file: production.yml
Output file: production.yml
redis uses an image, skipping
Building postgres
Step 1/4 : FROM postgres:11.3
---> 4e045cb8eecd
Step 2/4 : COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
---> Using cache
@lgvital
lgvital / gist:9fa8a07fcbc4af532e0470a799493da7
Created August 12, 2019 07:13
docker-compose conversion error
lionel@machine:~/code/cookiecutter_aws (master)$ python convert-docker-compose-to-aws.py
DOCKERHUB_USER=lionelv
Input file: production.yml
Output file: production.yml
redis uses an image, skipping
Building postgres
Step 1/4 : FROM postgres:11.3
---> 4e045cb8eecd
Step 2/4 : COPY ./compose/production/postgres/maintenance /usr/local/bin/maintenance
---> Using cache
@lgvital
lgvital / prepare-commit-msg
Last active October 28, 2019 21:38
hook to find clubhouse story in branch name and add to commit
#!/usr/bin/env python
"""
Adds clubhouse story # to your commit message.
1. Replace CLUBHOUSE_URL and TASK_REPLACE_STR
2. Copy this file to $GITREPOSITORY/.git/hooks/prepare-commit-msg
3. Mark hook as executable. e.g. chmod -x .git/hooks/prepare-commit-msg
"""
import sys, os, re
def efficiency_for_team_dates(company, team_id, granularity, ref_dates):
team = Team.load_id(team_id)
projects = team.projects_for(ProjectType.GITHUB)
for project in projects.itervalues():
for ref_date in ref_dates:
start, end = StatsGranularity.get_extents(
granularity, ref_date, team.timezone)
calculate_efficiency.delay(
company, project.id, project.foreign_id, start, end)