Giter Club home page Giter Club logo

puget-sound's Introduction

#travis ci tests travis-ci Tests

Server Install Requirements

Download and install virtualbox
Download and install vagrant (vagrantup.com)
Pull down the source code from Github
cd into the source directory with your terminal

Server Setup

Vagrant

vagrant plugin install vagrant-omnibus # for chef
vagrant plugin install vagrant-vbguest
vagrant up
easy_install pip #(if you do not already have)
pip install fabric #(if you do not already have)
fab vagrant bootstrap
fab vagrant createsuperuser
fab vagrant runserver

Loading Data

From Fixtures

fab vagrant loaddata

From the currently running instance

fab staging:[email protected] backup_db
fab vagrant restore_db:backups/2013-11-261230-geosurvey.dump
fab staging:[email protected] migrate_db



## Provision a fresh Server with Chef and Fabric
Create a node file with the name scripts/cookbook/node_staging.json from the template in scripts/cookbook/node_staging.json.template.  Set the postgresql password and add your ssh public key to scripts/node_staging.json.  Tested with Ubuntu 12.04 (precise pangolin).

These commands install all the prerequisites for running marine planner, including postgresql/postgis, python and all the required modules in a virtual environment as well as gunicorn and nginx to serve the static files.

```bash
fab staging:root@hostname prepare
fab staging:username@hostname deploy

###Sample config file

{
    "user": "www-data",
    "servername": "staging.example.com",
    "dbname": "marine-planner",
    "staticfiles": "/usr/local/apps/marine-planner/mediaroot",
    "mediafiles": "/usr/local/apps/marine-planner/mediaroot",
    "users": [
        {
            "name": "jsmith",
            "key": "ssh-rsa AAAAB3sdkfjhsdkhjfdjkhfffdj.....fhfhfjdjdfhQ== [email protected]"
        }
    ],
    "postgresql": {
        "password": {
            "postgres": "some random password here"
        }
    },
    "run_list": [
        "marine-planner::default"
    ]
}

After the prepare command runs you will no longer be able to login as root with a password. The prepare command creates one or more users with sudo access based on the list of users specified in the json file.

#Heroku ##requirements

  1. Install the heroku toolbelt.
  2. Install git > 1.8

##create the heroku app if it doesn't exist

heroku create appname

##login to heroku

heroku login

##set environment vars and install addons.

heroku config:add DJANGO_SECRET_KEY=SECRET!
heroku addons:add sendgrid
heroku addons:add redistogo
heroku addons:add pgbackups

Or run the script from scripts/heroku-env.sh, which is available on google drive for each deployment.

#Deploy

First push the server directory as a subtree from the master branch to heroku. Then you can use a subtree split to push an alternate branch.

##push the app from the project directory

git subtree push --prefix server/ heroku master

##push an alternate branch from the project directory

git push heroku `git subtree split --prefix server testbranch`:master

##django install

heroku run python manage.py syncdb --settings=config.environments.heroku
heroku run python manage.py migrate --settings=config.environments.heroku

##load some data

heroku run python manage.py loaddata apps/survey/fixtures/surveys.json --settings=config.environments.heroku
heroku run python manage.py loaddata apps/places/fixtures/marco.json.gz --settings=config.environments.heroku

##open the app

heroku open

#manage the heroku database

##dump a backup This will dump a compressed binary backup of the current database to a file that can be retrieved as "latest.dump".

heroku pgbackups:capture --expire
curl -o `date +%Y%m%d%H%M`.dump `heroku pgbackups:url`

##restore a backup To restore to the vagrant instance, log in to the vm and execute the following

pg_restore --verbose --clean --no-acl --no-owner -d geosurvey 201309170950.dump

Transfer the dump file to a web accessible space. To find the database url, use the pg:info command.

heroku pg:info
heroku pgbackups:restore DATABASE_URL 'http://www.example.org/latest.dump'

Troubleshooting

3/10/2014

Running this on a Mac upgraded to Mavericks runs into some problems. Bascially you need to rebuilt easy_install using the correct version of python (2.7). See here.

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo PATH_TO_PYTHON/python ez_setup.py
sudo easy_install -U pip

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.