Giter Club home page Giter Club logo

schdl's Introduction

Setting up Schdl

These directions assume a brand new VM running on Google Compute Engine with Ubuntu 18.04 LTS. To enable deploying to App Engine, the VM should be configured under "Cloud API access scopes" to "Allow full access to all Cloud APIs."

Initial setup

sudo apt-get update
git clone https://github.com/emosenkis/schdl
cd schdl
./setup.sh

Enter the dev environment (do this every time you want to build

cd $HOME/schdl
. schdl.env
. venv/bin/activate

Create a new school entry in the database

bin/addSchool.py --fragment testu --name Test\ University --email_domain test.com --website test.com --hostname 127.0.0.1
bin/ensureIndices.py

Copy the following into ~/schdl/gae/app.yaml

runtime: python
env: flex

runtime_config:
    python_version: 2

entrypoint: gunicorn -c gunicorn.conf.py -b :$PORT schdl.wsgi:app

env_variables:
    FLASK_MAIL_SERVER: 'MAIL_SERVER'
    FLASK_MAIL_PORT: 'MAIL_PORT'
    FLASK_MAIL_USE_TLS: 'MAIL_TLS_ENABLED'
    FLASK_MAIL_PASSWORD: 'PASSWORD'
    FLASK_MAIL_USERNAME: 'USERNAME'
    FLASK_MAIL_SENDER: 'MAIL_SENDER'
    FLASK_SECRET_KEY: 'SECRET'
    SCHDL_DB_URI: 'MONGODB_URI'
    SCHDL_GCS_BUCKET: 'GCS_BUCKET'
    SCHDL_EMAIL_ERRORS_TO: 'ERRORS_EMAIL'

skip_files:
    - ^\.git/.*
    - ^venv/.*

automatic_scaling:
    min_num_instances: 2
    max_num_instances: 3
    cpu_utilization:
        target_utilization: 0.6

resources:
    cpu: 1
    memory_gb: 1.5
  • Replace MAIL_SERVER with your SMTP server.
  • Replace MAIL_PORT with your SMTP port (this must not be a standard SMTP port)
  • Replace MAIL_TLS_ENABLED with 'true' or 'false'
  • Replace PASSWORD with your mail server password.
  • Replace USERNAME with your mail server username.
  • Replace MAIL_SENDER with the From address to be used for emails sent by the app.
  • Replace SECRET with a random string of about 30 characters. This is used to sign user sessions. Changing it and redeploying will force log out all users.
  • Replace MONGODB_URI with the MongoDB connection URI.
  • Replace GCS_BUCKET with the name of the Google Cloud Storage bucket that will be used to store course catalog snapshots and updates.
  • Replace EMAIL_ERRORS_TO with a space-separated list of email addresses that will be emailed anytime an error occurs (this can be omitted or left blank to not send a message for every error).

Important: Keep your app.yaml safe - it's stored outside of git because it contains your authentication credentials and secret key.

Build the UI and prepare a deployment directory

./build.sh ~/schdl-deploy

Enter the prod-like deployment environemtn

WARNING: Commands run this way will impact the production database and Cloud Storage configured in app.yaml.

cd ~/schdl
. venv/bin/activate
cd ~/schdl-deploy
. prod.env

You can now run scripts from the bin directory:

  • devServer.py to run a development server backed by the prod database (append ?force_host=prod-host.name to your URL when opening this in your browser to indicate the correct school to use).
  • setAPIKey.py to update the API key used to publish data updates.
  • generateSnapshot.py to generate a snapshot file, which can then be uploaded to Cloud Storage in place of the latest snapshot in case the snapshot somehow gets corrupted.

Deploy the version in the schdl-deploy directory to App Engine

Before the first time you'll do this, you'll need to first open the App Engine section of the Google Cloud Console, create a Python Flexible environment app, and choose a region that the app will run in.

gcloud app deploy
# When doing first-time deployment or if you've changed cron.yaml:
gcloud app deploy cron.yaml

schdl's People

Contributors

emosenkis avatar

Watchers

James Cloos avatar  avatar

Forkers

brandeis-its

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.