From 635b65d448686da42cf9c17fab0bb06dd177d7ea Mon Sep 17 00:00:00 2001 From: Jamie Alessio Date: Tue, 6 Sep 2016 16:56:35 -0700 Subject: [PATCH] Cloud quickstart instructions and scripts --- README-cloud.md | 57 +++++++++++++++++++ README.md | 14 +++-- .../conf.d/calthorpe.supervisor.prod | 4 +- quickstart.sh | 54 +++++++++++++----- 4 files changed, 109 insertions(+), 20 deletions(-) create mode 100644 README-cloud.md diff --git a/README-cloud.md b/README-cloud.md new file mode 100644 index 0000000..68838c5 --- /dev/null +++ b/README-cloud.md @@ -0,0 +1,57 @@ +# UrbanFootprint Cloud Installation + +These are the recommended steps for getting up and running with a demo UrbanFootprint production instance on a cloud server. + +## Prerequisites + +You'll need: + +* A dedicated server running [Ubuntu 14.04](https://wiki.ubuntu.com/TrustyTahr/ReleaseNotes) that you have ssh access to. On AWS, we recommend *"Ubuntu Server 14.04 LTS (HVM), SSD Volume Type"* +* A user account with root privileges (usually via sudo). + +We recommend at least 2 CPUs and 8GB of RAM. On AWS, select t2.large or larger [instance type](https://aws.amazon.com/ec2/instance-types/). + +## Installation + +We provide a "quickstart" script that handles installing all dependencies and pre-loads a sample data set. + + wget https://raw.githubusercontent.com/CalthorpeAnalytics/urbanfootprint/master/quickstart.sh + chmod +x quickstart.sh + sudo ./quickstart.sh + +Expect this script to take 15-20 minutes to complete. You'll know it's done when you see something like this: + + ******************************************************************** + ******************************************************************** + + UrbanFootprint quickstart is complete. Open your web browser to: + http:/// + using the following default credentials: + user: admin@urbanfootprint.net + pass: admin@uf + + ******************************************************************** + ******************************************************************** + + +# Using UF + +## Login with the default login + +The quickstart script will attempt to detect the public IP address of the server and print out a URL to use. If that doesn't work, determine the server's IP address using your cloud provider's tools and put the IP address in your web browser's location bar. + +When you first access your UF instance, you will be directed to the login page. +Login credentials are the following: + +>username: `admin@urbanfootprint.net` + +>password: `admin@uf` + +For information on how to create new users, please reference the +[User Manager](http://urbanfootprint-v1.readthedocs.io/en/latest/user_manager/) section of the documentation. + +## User Guide + +[http://urbanfootprint-v1.readthedocs.io/en/latest/](http://urbanfootprint-v1.readthedocs.io/en/latest/) + +Copyright (C) 2016 [Calthorpe Analytics](http://calthorpeanalytics.com/) diff --git a/README.md b/README.md index 6eb7dbf..01030a7 100644 --- a/README.md +++ b/README.md @@ -15,12 +15,16 @@ UrbanFootprint is developed by [Calthorpe Analytics](http://calthorpeanalytics.c Interested in installing UrbanFootprint on your own computer? -The fastest way to get up and running with a local UrbanFootprint installation is by using a pre-built -virtual machine. - --- -# UF Quickstart - Use a Pre-built VM +# UF Quickstart Cloud + +To run a version of UrbanFootprint on your own server (such as an AWS EC2 instance), follow the instructions in **[README-cloud.md](README-cloud.md)**. + +# UF Quickstart Local - Use a Pre-built VM + +The fastest way to get up and running with a local UrbanFootprint installation is by using a pre-built +virtual machine. ### Quickstart Prerequisites for Mac OS X and MS Windows: @@ -44,7 +48,7 @@ A local UrbanFootprint instance is now accessible via [http://localhost:3333/fo If you're looking to do active code development on the UrbanFootprint code base, then you'll need to install a development environment. Detailed installation instructions are available for Mac OS X -and MS Windows in [README-developers.md](README-developers.md) +and MS Windows in **[README-developers.md](README-developers.md)** # UrbanFootprint Client Configuration diff --git a/conf/etc/supervisor/conf.d/calthorpe.supervisor.prod b/conf/etc/supervisor/conf.d/calthorpe.supervisor.prod index b9bdc50..0da76c2 100644 --- a/conf/etc/supervisor/conf.d/calthorpe.supervisor.prod +++ b/conf/etc/supervisor/conf.d/calthorpe.supervisor.prod @@ -1,5 +1,5 @@ [program:calthorpe_www] -command=/srv/calthorpe_env/bin/newrelic-admin run-program /srv/calthorpe_env/bin/python /srv/calthorpe/urbanfootprint/manage.py run_gunicorn -w 12 -b 127.0.0.1:9001 -t 180 --max-requests 250 +command=/srv/calthorpe_env/bin/newrelic-admin run-program /srv/calthorpe_env/bin/python /srv/calthorpe/urbanfootprint/manage.py run_gunicorn -w 6 -b 127.0.0.1:9001 -t 180 --max-requests 250 directory=/srv/calthorpe/urbanfootprint user=www-data autostart=true @@ -25,7 +25,7 @@ killasgroup=true [program:tilestache] environment=NEW_RELIC_CONFIG_FILE="/etc/newrelic/newrelic_tilestache.ini",PATH="/srv/calthorpe_env/bin:/usr/bin" -command=/srv/calthorpe_env/bin/newrelic-admin run-program /srv/calthorpe_env/bin/gunicorn "TileStache.Goodies.PGConfigServer:WSGIServer('/srv/calthorpe/urbanfootprint/.env')" -b 127.0.0.1:8484 -w 12 --log-level=INFO --timeout 180 +command=/srv/calthorpe_env/bin/newrelic-admin run-program /srv/calthorpe_env/bin/gunicorn "TileStache.Goodies.PGConfigServer:WSGIServer('/srv/calthorpe/urbanfootprint/.env')" -b 127.0.0.1:8484 -w 6 --log-level=INFO --timeout 180 directory=/srv/calthorpe_env/lib/python2.7/site-packages/ user=www-data stdout_logfile=/var/log/supervisor/tilestache.log diff --git a/quickstart.sh b/quickstart.sh index e46d1c2..2bf43b0 100755 --- a/quickstart.sh +++ b/quickstart.sh @@ -10,39 +10,67 @@ echo "********************************************************************" echo "********************************************************************" echo "" -# working directory for all UF command -cd /srv/calthorpe/urbanfootprint +apt-get update +apt-get install -y software-properties-common +apt-add-repository -y ppa:ansible/ansible-1.9 +apt-get update +apt-get install -y ansible git +mkdir -p /srv/calthorpe/ + +# clone urbanfootprint repos +cd /srv/calthorpe/ +git clone https://github.com/CalthorpeAnalytics/urbanfootprint.git urbanfootprint +git clone https://github.com/CalthorpeAnalytics/urbanfootprint-configuration.git urbanfootprint-configuration +cd /srv/calthorpe/urbanfootprint/ +git submodule init +git submodule update + +# run ansible provisioning +cd /srv/calthorpe/urbanfootprint/provisioning +ansible-galaxy install -f -r galaxy-roles.yml +ansible-playbook -v -i 'localhost', -c local site.yml + +# let calthorpe user ssh in for fabric +su - calthorpe -c "ssh-keygen -f ~/.ssh/id_rsa -N ''" +su - calthorpe -c "ssh-keyscan -H localhost > ~/.ssh/known_hosts" +su - calthorpe -c "cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys" + +# set file permissions +chown -R calthorpe:calthorpe /srv/calthorpe/urbanfootprint* # stop all services -sudo supervisorctl stop all -sudo service supervisor stop -sudo service postgresql restart +supervisorctl stop all +service supervisor stop +service postgresql restart -# install python dependencies -pip install -r requirements.txt +# install python dependencies (though really all we need is fabric as this point) +/srv/calthorpe_env/bin/pip install -r /srv/calthorpe/urbanfootprint/requirements.txt +chown -R calthorpe:calthorpe /srv/calthorpe_env # copy sample environment settings for default configuration -cp .env.sample .env +cp /srv/calthorpe/urbanfootprint/.env.sample /srv/calthorpe/urbanfootprint/.env +chown calthorpe:calthorpe /srv/calthorpe/urbanfootprint/.env # retrieve sample web database -wget -O urbanfootprint-sacog-web-db.sql.gz https://s3-us-west-2.amazonaws.com/uf-provisioning/urbanfootprint-sacog-web-db.sql.gz -gunzip -f urbanfootprint-sacog-web-db.sql.gz +wget -O /srv/datadump/urbanfootprint-sacog-web-db.sql.gz https://s3-us-west-2.amazonaws.com/uf-provisioning/urbanfootprint-sacog-web-db.sql.gz +gunzip -f /srv/datadump/urbanfootprint-sacog-web-db.sql.gz # import sample web database psql -U postgres -c "DROP DATABASE IF EXISTS urbanfootprint;" psql -U postgres -c "CREATE DATABASE urbanfootprint;" psql -U postgres -c "GRANT ALL ON DATABASE urbanfootprint TO calthorpe;" -psql -U postgres urbanfootprint < urbanfootprint-sacog-web-db.sql +psql -U postgres urbanfootprint < /srv/datadump/urbanfootprint-sacog-web-db.sql # finish installation and deployment process -fab -f footprint/installer localhost quickstart +su - calthorpe -c "/srv/calthorpe_env/bin/fab -f /srv/calthorpe/urbanfootprint/footprint/installer localhost quickstart" +external_ip=$(curl -s 'https://api.ipify.org') echo "" echo "********************************************************************" echo "********************************************************************" echo "" echo " UrbanFootprint quickstart is complete. Open your web browser to:" -echo " http://localhost:3333/footprint/" +echo " http://${external_ip}/" echo " using the following default credentials:" echo " user: admin@urbanfootprint.net" echo " pass: admin@uf"