forked from canvasnetworks/canvas
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.txt
167 lines (126 loc) · 6.57 KB
/
README.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
==========
| Canvas |
==========
This is the entire Canvas repo, including application code and configuration, without being cleaned up and prepped for renewed use. It's definitely doable to get this back into a running state, but please treat the configuration management parts as documentation more than pieces of reusable automation.
As for the bits of DrawQuest in this repo: for a while we ran both sites out of the same repo (the DrawQuest backend requirements were happily similar to what we'd already built with Canvas); once that became a burden, we stopped forking in code and forked in git instead.
## The instructions below are also untouched. They won't help as-is but may be a helpful guide to piece things back together.
If you have any questions feel free to reach out to [email protected]
Note: Use of the registered "CANVAS" trademark is not conferred by the LICENSE. You may not use "Canvas" in the name of any derivative works without prior written permission.
----------
1. Prerequisites:
=================
OS X
----
# MANUALLY: Install XCode via thumb drive or App Store
xcode-select --install
java # type this, press enter, will prompt you to install Java
ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
brew install git ack redis nginx pil solr wget memcached # requires installed XCode
sudo ln -s /usr/local/lib/python2.7/site-packages/PIL* /Library/Python/2.7/site-packages/
# Port 80/443 support
cd /tmp
wget https://s3.amazonaws.com/canvas-public-artifacts/canvas_forward_http.tgz
tar -xzf ./canvas_forward_http.tgz
sudo ./canvas_forward_http.app/Contents/MacOS/Injector
# MANUAL STEP (Window may pop up behind other windows if you're using spaces): Press "Inject" button
# PhantomJS
cd /tmp
wget https://s3.amazonaws.com/canvas-public-artifacts/qt-mac-opensource-4.7.4.dmg
# You can just install the DMG manually or run the following command.
hdiutil attach qt-mac-opensource-4.7.4.dmg && cd /Volumes/Qt\ 4.7.4/ && sudo installer -pkg Qt.mpkg -target / && cd -
mkdir -p ~/Packages && cd ~/Packages
# DO THIS IN ~/Packages
wget https://s3.amazonaws.com/canvas-public-artifacts/phantomjs-1.5.0-macosx-static.zip && unzip phantomjs-1.5.0-macosx-static.zip
# PySide
cd /tmp
wget https://s3.amazonaws.com/canvas-public-artifacts/pyside-1.1.0-qt47-py27apple.pkg
open pyside-1.1.0-qt47-py27apple.pkg
# Follow the installation wizard.
Everwhere
---------
# ENSURE you have an encrypted location to place your Canvas files (use FileVault for OSX, encrypted home/private in Ubuntu)
# http://viktorpetersson.com/2011/08/01/did-you-know-you-can-create-encrypted-partitions-in-os-x-lion/
cd $PATH_TO_YOUR_ENCRYPTED_LOCATION
git config --global user.name "Your Name"
git config --global user.email [email protected]
# Ensure your new ssh public key (`ssh-keygen`) is uploaded to your GitHub account at this point.
git clone [email protected]:canvasnetworks/canvas.git
sudo ln -s "`pwd`/canvas" /var/canvas
# Add canvas bash commands
echo ". /var/canvas/.bashrc" >> ~/.bash_profile && source ~/.bash_profile
# Install python dependencies with pip
sudo easy_install pip
sudo /var/canvas/requirements/update_sandbox.sh
2. Setting up local data:
=========================
cd /var/canvas/website
python manage.py syncdb
redis-server redis.conf # migration needs redis
python manage.py migrate canvas
python manage.py migrate
runcanvas
python manage.py solr_import group && python manage.py solr_import comment
open http://savnac.com # and manually upload /var/canvas/website/static/img/600-600.png (allows upload from drawing)
3. Running Sass:
================
Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. ItÕs translated to well-formatted, standard CSS using the command line tool or a web-framework plugin.
A subset of the stylesheets used on the site are generated by Sass. The rule is that if a CSS file looks minified or all its content is in one
line then it is controlled by sass. Hence, look for it under /static/scss and change it there. There is a conversion step that needs to run after
making changes. But you can run the Sass Daemon and it will watch the files for changes and convert them as needed.
To install Sass, you'll need to have Ruby, then run the sass alias:
sudo gem install --version 3.1.15 sass
csass
4. Running the site:
====================
runcanvas
|epilogue|
==========
Logging:
========
In development mode, Django logs are written to /run/django_gunicorn.log.
You can use logs like this:
import logging
logging.debug("debug message").
You can also run a tail on the log file to see the log messages:
cdc
tail -f run/django_gunicorn.log
Reset local data:
=================
cd /var/canvas/website
rm db.sqlite
python manage.py syncdb
python manage.py migrate
redis-cli FLUSHALL
rm -rf /var/canvas/deploy/etcpuppet/modules/solr/files/solr/*/data
Data Migrations:
================
You need to migrate the database schema whenever you make changes to models that will affect the corresponding database tables.
We use a tool called South to make this easy. Here is how to use it:
1. First run the schema migration locally:
python manage.py schemamigration canvas --auto
This creates a South migration file in canvas/migrations/. It is a Python file. Open it and look through it to verify the changes make sense.
2. You should comment out code that uses the new changes until you've migrated the schema on production. To run the migrations in production, you'll have
to SSH into the Gateway[1]. The Gateway and other machines in production need to have your public key. Mike can do this for you.
a. SSH into the Gateway: There is a command for that! (defined in /var/canvas/.bashrc):
gw
If your username on your local machine is different from your @example.com username, then use this:
gw -l <@example.com username>
b. Once on the Gateway, you can SSH into Cron:
ssh `ip -rg cron`
(Note the backticks. It executed the enclosed command and it becomes the operand)
Now you're on Cron.
c. Execute the schema migration script on Cron:
python manage.py schemamigration canvas --auto
d. You can now push any code that uses the new schema.
[1] Gateway: It is a machine through which you can access other machines in the cluster. It is the only machine in the cluster that you can externally
SSH into.
The Canvas JavaScript API
=========================
The JavaScript api wrapper in statis/js/canvas_api.js is auto generated from api.py. Whenever you add a new api or change the signature of an api
method, you must regenerate the JS wrapper:
python manage.py generate_js_api
Profiling
=========
sudo pip install RunSnakeRun
mkdir -p ~/.config
runsnake foo.pstats