Skip to content

Commit c274235

Browse files
committed
Updated based on our latest workflow
1 parent 47cf041 commit c274235

File tree

9 files changed

+85
-271
lines changed

9 files changed

+85
-271
lines changed

buildout.cfg

+6-14
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ auto-checkout = *
1414
eggs =
1515
pillow
1616
django
17+
eventlet
1718
gunicorn
18-
# Enable flup if you want to use fastcgi instead of gunicorn
19-
# flup
2019

2120

21+
# The versions below are as example only, please change these to use
22+
# latest versions of packages you require
2223
[versions]
2324
pillow = 1.7.5
2425
django = 1.4.3
2526
gunicorn = 0.16.1
26-
# flup = 1.0.2
2727

2828

2929
[sources]
@@ -34,6 +34,7 @@ gunicorn = 0.16.1
3434
access_log = ${buildout:directory}/log/access.log
3535
instance_log = ${buildout:directory}/log/instance.log
3636
error_log = ${buildout:directory}/log/error.log
37+
supervisor_log = ${buildout:directory/log/supervisor.log
3738

3839

3940
[python]
@@ -50,20 +51,11 @@ settings = settings
5051
# The name of the wrapped manage.py, which will be placed in bin
5152
control-script =
5253
# The path to your project, this should be where your original manage.py is
53-
# located
54-
extra-paths = ${buildout:directory}/{{ PROJECT_DIR_NAME }}/
54+
# located.
55+
extra-paths = ${buildout:directory}/<INSERT_PROJECT_DIR_NAME>/
5556
eggs = ${buildout:eggs}
5657

5758

58-
# Add to parts if you want to use fabric
59-
[fabric-script]
60-
recipe = collective.recipe.template
61-
input = templates/fabtemplate.py
62-
output = ${buildout:directory}/fabfile.py
63-
staging-root =
64-
production-root =
65-
66-
6759
# Add to parts if you want to use compass
6860
[compass-config]
6961
recipe = collective.recipe.template

develop.cfg

-43
This file was deleted.

fabfile/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import production
2+

fabfile/production.py

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
from fabric.api import *
3+
from fabric.contrib.console import confirm
4+
5+
6+
# Set up the production environment vars
7+
env.hosts = []
8+
env.user = ''
9+
10+
# Set some helpful global vars
11+
SCRIPT_NAME = '' # This should be the same as you bin script name
12+
PROJECT_ROOT = "" # Root folder on the server
13+
projectroot = lambda *p: os.path.join(PROJECT_ROOT, *p)
14+
15+
16+
@task
17+
def make_archive(version="HEAD"):
18+
filename = "%s-%s.tar.gz" % (SCRIPT_NAME, version)
19+
local('git archive --format=tar %s | gzip >%s' % (version, filename))
20+
return filename
21+
22+
23+
@task
24+
def buildout():
25+
with cd(PROJECT_ROOT):
26+
run('./bin/buildout -c production.cfg')
27+
28+
29+
@task
30+
def deploy(version="HEAD"):
31+
if confirm("Deploy %s?" % version):
32+
archive = make_archive(version)
33+
put(archive, PROJECT_ROOT)
34+
with cd(PROJECT_ROOT):
35+
run('tar zxvf %s' % archive)
36+
else:
37+
abort("Aborting at user request")
38+

production.cfg

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,28 @@
11
[buildout]
22
extends = buildout.cfg
3-
parts += gunicorn nginx launcher
3+
parts += nginx supervisor-conf
44

55

66
[opts]
77
control-script = ${django:control-script}
8-
username =
8+
user =
9+
server_domain =
910
server_name =
1011
listen_port =
11-
app_host =
12-
app_port =
13-
media_dir = ${buildout:directory}/media/
14-
workers = 2
15-
# FastCGI options
16-
pidfile = ${buildout:directory}/bin/${opts:control-script}.pid
12+
media_dir = ${buildout:directory}/cdn/
13+
workers = 4
1714
socketfile = ${buildout:directory}/bin/${opts:control-script}.sock
1815

1916

20-
[gunicorn]
21-
recipe = zc.recipe.egg:scripts
22-
dependent-scripts = true
23-
eggs =
24-
${buildout:eggs}
25-
eventlet
26-
gunicorn
27-
28-
2917
[nginx]
3018
recipe = collective.recipe.template
3119
input = templates/nginx.conf
3220
output = ${buildout:directory}/nginx/${opts:control-script}.conf
3321

3422

35-
[launcher]
23+
[supervisor-conf]
3624
recipe = collective.recipe.template
37-
input = templates/launcher.sh
38-
output = ${buildout:directory}/bin/${opts:control-script}.sh
25+
input = templates/supervisor.conf
26+
output = ${buildout:directory}/supervisor/${opts:control-script}.conf
3927
mode = 755
4028

templates/fabtemplate.py

-90
This file was deleted.

templates/launcher.sh

-74
This file was deleted.

0 commit comments

Comments
 (0)