Coder Social home page Coder Social logo

bg_upgrades's Introduction

Works on my machine

Architecture

BG upgrades is using the django framework at its core.

The overall architecture should be pretty standard with one central form generated from tuckbox/templates/pattern_form.html.j2

It uses Redis and Celery to process the requests asynchronously (and report on progress).

Requirements

  • Python 3 (possibly also python3.X-dev on ubuntu)
  • imagemagick
  • nginx (for full deployment)
  • redis
  • chromedriver

Development

To setup an environment, use virtualenv and install the packages listed in requirements.txt

$ virtualenv [--python=/your/path/to/python3] venv
$ source venv/bin/activate
$ pip install -r requirements.txt
$ webdrivermanager chrome --linkpath [folder in your PATH]

To run the tests:

$ ./manage.py test --parallel

To get coverage report on the tests:

$ coverage run --source='.' --omit='venv/*' manage.py test --parallel
$ coverage report

or

$ coverage html

Run only Django's test server:

$ redis-server
$ watchmedo auto-restart --directory=./ --pattern="*.py" --recursive -- celery -A bg_upgrades worker -l info

$ ./manage.py migrate
$ ./manage.py runserver

Run uwsgi with the CLI options

$ uwsgi -H venv --socket mysite.sock --module bg_upgrades.wsgi --chmod-socket=664

Startup / Deploy

To deploy, you need to setup those environment variables:

  • DJANGO_DEBUG to 'False'

  • DJANGO_SECRET_KEY. This can be generated:

    $ python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'

  • DJANGO_PROJECT_PATH to the folder with the project

Configuration for nginx should be updated with the right paths and placed in the right folder

  • /usr/local/etc/nginx/servers/ on mac
  • /etc/nginx/servers/ on linux

Start all those different services:

$ redis-server
$ celery -A bg_upgrades worker -l info

$ ./manage.py migrate
$ ./manage.py collectstatic

$ uwsgi --ini uwsgi.ini

Start the nginx server $ brew services restart nginx

$ sudo /etc/init.d/nginx restart

Optionally:

$ flower -A bg_upgrades

The overall deployment framework is using nginx and uWSGI as documented (here)[https://uwsgi-docs.readthedocs.io/en/latest/tutorials/Django_and_nginx.html].

SSL / TLS

Set the environment variables: DOMAIN to bg-upgrades.net and WILDCARD to *.$DOMAIN

$ sudo add-apt-repository ppa:certbot/certbot
$ sudo apt install python-certbot-nginx
$ sudo certbot -d $DOMAIN -d $WILDCARD --nginx --preferred-challenges dns certonly

Instructions also (here)[https://www.nginx.com/blog/using-free-ssltls-certificates-from-lets-encrypt-with-nginx/]

Maintenance

To find packages that need to be updated, you can check this link or run $ pip list --outdated

Then update:

$ pip install <package_name> --upgrade

Whenever the packages change, record the packages:

$ pip-chill freeze > requirements.txt

When the reference data needs to change for the graphics tests, run:

$ python -m tuckbox.test.tests_box

If running into permissions issues for using 'PDF' in ImageMagick, follow those instructions

Dependencies

The libraries this web application uses:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.