[superlists.ottg.eu] out: Creating table auth_permission
[...]
[superlists.ottg.eu] out: Creating table lists_item
[superlists.ottg.eu] out: Installing custom SQL ...
[superlists.ottg.eu] out: Installing indexes ...
[superlists.ottg.eu] out: Installed 0 object(s) from 0 fixture(s)
[superlists.ottg.eu] out:
Done.
Disconnecting from superlists.ottg.eu... done.
Brrp brrp brpp
. You can see the script follows a slightly different path, doing a
git
clone
to bring down a brand new repo instead of a
git pull
. It also needs to set up a
new virtualenv from scratch, including a fresh install of pip and Django. The
collect
static
actually creates new files this time, and the
migrate
seems to have worked too.
Nginx and Gunicorn Config Using sed
What else do we need to do to get our live site into production? We refer to our provi‐
sioning notes, which tell us to use the template files to create our Nginx virtual host and
the Upstart script. How about a little Unix command-line magic?
elspeth@server:$
sed "s/SITENAME/superlists.ottg.eu/g" \
deploy_tools/nginx.template.conf | sudo tee \
/etc/nginx/sites-available/superlists.ottg.eu
sed
(“stream editor”) takes a stream of text and performs edits on it. It’s no accident that
the fabric string substitution command has the same name. In this case we ask it to
substitute the string
SITENAME
for the address of our site, with the
s/replaceme/
withthis/g
syntax. We pipe (
|
) the output of that to a root-user process (
sudo
), which
uses
tee
to write what’s piped to it to a file, in this case the Nginx sites-available vir‐
tualhost config file.
We can now activate that file:
elspeth@server:$
sudo ln -s ../sites-available/superlists.ottg.eu \
/etc/nginx/sites-enabled/superlists.ottg.eu
Then we write the upstart script:
elspeth@server:
sed "s/SITENAME/superlists.ottg.eu/g" \
deploy_tools/gunicorn-upstart.template.conf | sudo tee \
/etc/init/gunicorn-superlists.ottg.eu.conf
Finally we start both services:
elspeth@server:$
sudo service nginx reload
elspeth@server:$
sudo start gunicorn-superlists.ottg.eu
And we take a look at our site. It works, hooray!
Trying It Out
|
165