Skip to content

Instantly share code, notes, and snippets.

@orther
Last active July 29, 2017 15:33
Show Gist options
  • Save orther/6d0169739b2db4909485 to your computer and use it in GitHub Desktop.
Save orther/6d0169739b2db4909485 to your computer and use it in GitHub Desktop.
Example Makefile for Flask app using Chaussette
[watcher:api_web]
working_dir = /var/www/snapsho/current
copy_env = True
virtualenv = /var/www/snapsho
cmd = chaussette --fd $(circus.sockets.api) wsgi_machine_api.app
use_sockets = True
numprocesses = 5
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/circus/snapsho-api_err.log
stderr_stream.time_format = %Y-%m-%d %H:%M:%S
# rotate the log file when it reaches 1 gb
# and save N copies of rotated files
stderr_stream.max_bytes = 1073741824
stderr_stream.backup_count = 3
stdout_stream.class = FileStream
stderr_stream.filename = /var/log/circus/snapsho-api_out.log
# rotate the log file when it reaches 1 gb
# and save N copies of rotated files
stdout_stream.max_bytes = 1073741824
stdout_stream.backup_count = 3
[watcher:api_rqworker]
working_dir = /var/www/snapsho/current
copy_env = True
virtualenv = /var/www/snapsho
cmd = rqworker
numprocesses = 3
stderr_stream.class = FileStream
stderr_stream.filename = /var/log/circus/snapsho-rqworker_err.log
stderr_stream.time_format = %Y-%m-%d %H:%M:%S
# rotate the log file when it reaches 1 gb
# and save N copies of rotated files
stderr_stream.max_bytes = 1073741824
stderr_stream.backup_count = 3
stdout_stream.class = FileStream
stderr_stream.filename = /var/log/circus/snapsho-rqworker_out.log
# rotate the log file when it reaches 1 gb
# and save N copies of rotated files
stdout_stream.max_bytes = 1073741824
stdout_stream.backup_count = 3
[env:api_*]
DEBUG = 0
TESTING = False
SECRET_KEY = WOULDNTyouLIKEtoKNOW
PGSQL_HOST = localhost
PGSQL_PORT = 5432
PGSQL_PASS = PASSWORD_GOES_HERE
PGSQL_USER = USER_GOES_HERE
PGSQL_DB = DB_GOES_HERE
REDIS_HOST = some.redis.host
REDIS_PORT = 6379
REDIS_DB = 0
REDIS_URL = redis://some.redis.host:6379/0
AWS_ACCOUNT = 123456789
AWS_REGION = us-east-1
AWS_USER = aws-user-here
AWS_ACCESS_KEY_ID = BLAHBLAHID18739439437
AWS_SECRET_ACCESS_KEY = BLAHBLAHKEY8945893489534534985734985
[socket:api]
host = 127.0.0.1
port = 8000
.PHONY: help db-gen-migration dev-rqworker dev-machine-api dev-frontend dev-api clean clean-pyc clean-build list test test-all test-aws coverage docs release sdist
help:
@echo "clean-build - remove build artifacts"
@echo "clean-pyc - remove Python file artifacts"
@echo "coverage - check code coverage quickly with the default Python"
@echo "db-gen-migration - autogenerate alembic migration"
@echo "dev-admin - start admin http server for development (uses chaussette)"
@echo "dev-api - start api http server for development (uses chaussette)"
@echo "dev-dashboard - start dashboard http server for development (uses chaussette)"
@echo "dev-frontend - start frontend http server for development (uses chaussette)"
@echo "dev-machine-api - start api http server for development (uses chaussette)"
@echo "dev-rqworker - start rqworker for development"
@echo "docs - generate Sphinx HTML documentation, including API docs"
@echo "lint - check style with flake8"
@echo "release - package and upload a release"
@echo "sdist - package"
@echo "test - run tests quickly with the default Python"
@echo "testall - run tests on every Python version with tox"
clean: clean-build clean-pyc
clean-build:
rm -fr build/
rm -fr dist/
rm -fr *.egg-info
clean-pyc:
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
coverage:
coverage run --source snapsho_platform setup.py test
coverage report -m
coverage html
open htmlcov/index.html
db-gen-migration:
@read -p "Enter alembic migration message: " msg; \
alembic revision --autogenerate -m "$$msg"
dev-admin:
chaussette --host 0.0.0.0 --port 8081 --use-reloader wsgi_admin:app
dev-api:
chaussette --host 0.0.0.0 --port 8082 --use-reloader wsgi_api:app
dev-dashboard:
chaussette --host 0.0.0.0 --port 8083 --use-reloader wsgi_dashboard:app
dev-frontend:
chaussette --host 0.0.0.0 --port 8084 --use-reloader wsgi_frontend:app
dev-machine-api:
chaussette --host 0.0.0.0 --port 8085 --use-reloader wsgi_machine_api:app
dev-rqworker:
rqworker -c snapsho_platform.settings
docs:
rm -f docs/snapsho_platform.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ snapsho_platform
$(MAKE) -C docs clean
$(MAKE) -C docs html
open docs/_build/html/index.html
lint:
flake8 snapsho_platform
release: clean
python setup.py sdist upload
python setup.py bdist_wheel upload
sdist: clean
python setup.py sdist
python setup.py bdist_wheel upload
ls -l dist
test:
nosetests
test-aws:
nosetests */aws
test-all:
tox
# -*- coding: utf-8 -*-
"""
wsgi_api
~~~~~~~~
snapsho_platform wsgi module
"""
from snapsho_platform import api
app = api.create_app()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment