Commits

Dmitri Lebedev committed 83c9ece Draft

updated roles: now can install the site as prod, dev or other roles using make install_prod or install_dev.

Comments (0)

Files changed (6)

 
 syncdb
 static/CACHE
+deploy
 run: bin/django syncdb compile_trans
 	./bin/django runserver 0.0.0.0:8000
 
-.PHONY: run_prod
-runprod: bin/django compile_trans
-	./bin/prod runserver 0.0.0.0:8000  # replace this with more sensible (like "apache/bin/restart")
-
 .PHONY: werkzeug
-runserver_plus: bin/django syncdb
+werkzeug: bin/django syncdb
 	./bin/django runserver_plus
 
 .PHONY: shell_plus
 shell_plus: bin/django syncdb
 	./bin/django shell_plus
 
-.PHONY: shell_plus_prod
-shell_plus_prod: bin/django syncdb
-	./bin/prod shell_plus
-
-.PHONY: check_pyflakes
-check_pyflakes: bin/pyflakes
-	find . -name '*.py' -exec ./bin/pyflakes {} \;
-
 bin/django: bin/buildout buildout.cfg
 	./bin/buildout && touch bin/django bin/prod
 
 	python bootstrap.py --distribute
 
 syncdb: bin/django
-	./bin/django syncdb && touch syncdb
+	./bin/django syncdb --noinput && touch syncdb
 
 .PHONY: make_trans
 make_trans: bin/django
 .PHONY: rebuilddb
 rebuilddb: bin/django
 	bin/django reset_db --router=default --noinput
-	bin/django syncdb --noinput
+	bin/django syncdb --noinput && touch syncdb
+
+.PHONY: install_prod install_dev
+install_prod:
+	ln -f -s buildout.prod.cfg buildout.cfg
+
+install_dev:
+	ln -f -s buildout.dev.cfg buildout.cfg

buildout.cfg

-# Prerequisites
-
-# sudo apt-get install libxslt-dev python-dev libpq-dev rubygems make
-# sudo apt-get install openjdk-6-jre-headless --no-install-recommends
-
-
-# Django compressor requires lxml
-# lxml requires libxslt-dev and python-dev installed in system
-
-
-[buildout]
-# add local subrepos that have setup.py to develop eggs in 'develop =' section.
-# gp.recipe.node works only from the repo, not from pypi
-develop = djaml
-
-# do not use custom python packages installed in the system
-include-site-packages = false
-
-# hamlpy needs a patch that this subrepo has
-parts =
-	django
-	cleanup
-	sass
-	yuic
-
-project = project
-eggs =
-	django >= 1.4, <1.5
-#	mock 						# useful for mocking some objects in unit tests
-#	django-reversion == 1.5.1	# useful for keeping revisions of objects
-	ipython >= 0.13 			# advanced interactive Python shell
-	ipdb 						# IPython debugger
-	django_extensions == 0.9 	# shell_plus
-	django-annoying == 0.7.6 	# a set of decorators and middleware to simplify coding
-	django-debug-toolbar 		# cool debugging
-	werkzeug 					# WSGI debug post-mortem shell in the page
-#	django-tastypie == 0.9.11 	# RESTful API for models
-#	Pillow 						# replacement of PIL
-#	pudb 						# console debugging IDE
-	django_compressor == 1.2	# js/css compressor/compiler
-	BeautifulSoup 				# required by compressor
-	html5lib 					# required by compressor
-	lxml 						# required by compressor
-#	versiontools 				# required by reversion
-	hamlpy 						# HAML templates
-	djaml 						# hamlpy loader
-
-
-[sass]
-project = ${buildout:project}
-recipe = rubygemsrecipe
-gems =
-	sass
-
-
-[coffee]
-recipe = gp.recipe.node
-npms =
-    coffee-script
-scripts =
-	coffee
-	npm
-
-
-[django]
-recipe = djangorecipe
-project = ${buildout:project}
-settings = dev
-wsgi = true
-eggs = ${buildout:eggs}
-
-
-[prod]
-recipe = djangorecipe
-project = ${buildout:project}
-settings = prod
-wsgi = true
-eggs = ${buildout:eggs}
-
-
-[cleanup]
-recipe = collective.recipe.cmd
-on_install = true
-on_update = true
-cmds =
-	find ${buildout:project} -name '*.py[co]' -delete
-
-
-[yuic]
-# YUI compressor. Minifies JS files.
-recipe = zc.recipe.egg
-eggs = yuicompressor

buildout.common.cfg

+# Prerequisites
+
+# sudo apt-get install libxslt-dev python-dev libpq-dev rubygems make
+# sudo apt-get install openjdk-6-jre-headless --no-install-recommends
+
+
+# Django compressor requires lxml
+# lxml requires libxslt-dev and python-dev installed in system
+
+
+[buildout]
+# add local subrepos that have setup.py to develop eggs in 'develop =' section.
+# gp.recipe.node works only from the repo, not from pypi
+develop = djaml
+role = dev
+
+domain = localhost
+# name your site here
+sitename = fastdev-django
+
+
+# do not use custom python packages installed in the system
+include-site-packages = false
+
+# hamlpy needs a patch that this subrepo has
+parts =
+	django
+	cleanup
+	sass
+	yuic
+	uwsgi
+
+project = project
+eggs =
+	django >= 1.4, <1.5
+#	mock 						# useful for mocking some objects in unit tests
+#	django-reversion == 1.5.1	# useful for keeping revisions of objects
+	django_extensions == 0.9 	# shell_plus
+	django-annoying == 0.7.6 	# a set of decorators and middleware to simplify coding
+	django-debug-toolbar 		# cool debugging
+#	django-tastypie == 0.9.11 	# RESTful API for models
+#	Pillow 						# replacement of PIL
+#	pudb 						# console debugging IDE
+	django_compressor == 1.2	# js/css compressor/compiler
+	BeautifulSoup 				# required by compressor
+	html5lib 					# required by compressor
+	lxml 						# required by compressor
+#	versiontools 				# required by reversion
+	hamlpy 						# HAML templates
+	djaml 						# hamlpy loader
+
+
+[sass]
+project = ${buildout:project}
+recipe = rubygemsrecipe
+gems =
+	sass
+
+
+[coffee]
+recipe = gp.recipe.node
+npms =
+	coffee-script
+scripts =
+	coffee
+	npm
+
+
+[django]
+recipe = djangorecipe
+project = ${buildout:project}
+settings = ${buildout:role}
+wsgi = true
+eggs = ${buildout:eggs}
+
+
+[cleanup]
+recipe = collective.recipe.cmd
+on_install = true
+on_update = true
+cmds =
+	find ${buildout:project} -name '*.py[co]' -delete
+
+
+[yuic]
+# YUI compressor. Minifies JS files.
+recipe = zc.recipe.egg
+eggs = yuicompressor
+
+
+[uwsgi]
+recipe = collective.recipe.cmd
+on_install = true
+on_update = true
+
+host = 127.0.0.1
+port = 27001
+connection = ${uwsgi:host}:${uwsgi:port}
+# or a unix socket for slightly better performance
+
+cmds =
+	mkdir -p deploy
+	cat > deploy/nginx.conf <<EOF
+		server {
+			listen 80;
+			server_name ${buildout:domain};
+			location /s/ {
+				root ${buildout:directory}/${buildout:project}/static/;
+				expires 30d;
+				access_log off;
+				rewrite ^/s/(.*) /\$1 break;
+			}
+
+			location / {
+				include uwsgi_params;
+				uwsgi_pass ${uwsgi:connection};
+				root ${buildout:directory};
+			}
+
+			charset utf-8;
+			access_log /var/log/nginx/${buildout:sitename}-access.log;
+			error_log /var/log/nginx/${buildout:sitename}-error.log;
+			client_max_body_size 300m;
+		}
+	EOF
+
+	cat > deploy/uwsgi_${buildout:role}.ini <<EOF
+		[uwsgi]
+		plugins = python
+		socket = ${uwsgi:connection}
+		master = true
+		processes = 4
+		wsgi-file = bin/django.wsgi
+	EOF
+[buildout]
+extends = buildout.common.cfg
+role = dev
+parts =
+	django
+	cleanup
+	sass
+	yuic
+
+
+eggs +=
+	ipython >= 0.13 			# advanced interactive Python shell
+	ipdb 						# IPython debugger
+	werkzeug 					# WSGI debug post-mortem shell in the page

buildout.prod.cfg

+[buildout]
+extends = buildout.common.cfg
+role = prod
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.