-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default nginx config for django, log folder and bare scripts for star…
…tup. Summary: Basic setup for nginx Test Plan: run start and stop scripts and runserver in between. Reviewers: bogdan2412 Reviewed By: bogdan2412 Differential Revision: http://phab.code4fun.de/D5
- Loading branch information
Showing
7 changed files
with
150 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
*.swp | ||
local_settings.py | ||
db.sqlite3 | ||
.nginx_conf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
worker_processes 5; | ||
worker_rlimit_nofile 8192; | ||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
http { | ||
# replace the following: | ||
# $nginx_etc with /usr/local/etc/nginx for mac or /etc/nginx for linux | ||
# set $project_name to the path to the project/app_name | ||
# eg: /Users/Mati/mati/work/CodeStreak/CodeStreak; | ||
include $nginx_etc/mime.types; | ||
include $nginx_etc/proxy.conf; | ||
default_type application/octet-stream; | ||
|
||
sendfile on; | ||
keepalive_timeout 65; | ||
|
||
error_log /tmp/CodeStreak.nginx.log error; | ||
log_format main | ||
'$remote_addr - $remote_user [$time_local] ' | ||
'"$request" $status $bytes_sent ' | ||
'"$http_referer" "$http_user_agent" ' | ||
'"$gzip_ratio"'; | ||
|
||
upstream django { | ||
server unix:///tmp/CodeStreak.sock; # for a file socket | ||
# server 127.0.0.1:8001; # for a web port socket | ||
} | ||
|
||
server { | ||
root $project_name; | ||
|
||
# the port your site will be served on | ||
listen 8000; | ||
# the domain name it will serve for | ||
server_name 127.0.0.1 localhost; | ||
charset utf-8; | ||
|
||
#Max upload size | ||
client_max_body_size 75M; # adjust to taste | ||
|
||
location ~ ^/static/(.*)$ { | ||
alias static_collected/$1; | ||
expires 1d; | ||
} | ||
|
||
location ~ ^/media/(.*)$ { | ||
alias media/$1; | ||
expires 1d; | ||
} | ||
|
||
location ~ /favicon.ico { | ||
alias static_collected/img/favicon.png; | ||
expires 1d; | ||
} | ||
|
||
# Finally, send all non-media requests to the Django server. | ||
location / { | ||
# all proxy headers should have been set | ||
uwsgi_pass django; | ||
include $nginx_etc/uwsgi_params; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from CodeStreak.settings import * | ||
DEBUG = True | ||
TEMPLATE_DEBUG = DEBUG |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,62 @@ | ||
# /bin/bash | ||
|
||
MEMCACHED_PORT=11211 | ||
# just inc ase, we define base python here | ||
if [ -z $PYTHON ]; | ||
then | ||
PYTHON=python | ||
fi | ||
|
||
start_memcached() | ||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
start_uwsgi() | ||
{ | ||
memcached -p $MEMCACHED_PORT & | ||
MEMCACHED_PID=$! | ||
echo "Starting memcached: pid=$MEMCACHED_PID" | ||
echo "Starting uWSGI" | ||
# TODO: fix permissions to 664, put user, nginx in same group and such.. | ||
uwsgi \ | ||
--socket /tmp/CodeStreak.sock \ | ||
--chmod-socket=666 \ | ||
--chdir $DIR \ | ||
--wsgi-file $DIR/CodeStreak/wsgi.py \ | ||
--master true \ | ||
--processes 10 \ | ||
--vacuum true \ | ||
$@ | ||
} | ||
|
||
kill_memcached() | ||
start_fcgi() | ||
{ | ||
kill $MEMCACHED_PID | ||
echo "Killing memcached: pid=$MEMCACHED_PID" | ||
exit $? | ||
echo "Starting FCGI" | ||
$PYTHON manage.py runfcgi \ | ||
# method=prefork \ | ||
socket=/tmp/CodeStreak.socket \ | ||
# host=127.0.0.1 port=8080 \ | ||
settings=CodeStreak/settings_debug.py \ | ||
pidfile=/tmp/Codestreak.django.pid \ | ||
$@ | ||
} | ||
|
||
# trap kill_memcached SIGINT | ||
start_normal() | ||
{ | ||
echo "Starting $PYTHON" | ||
$PYTHON manage.py runserver $@ | ||
} | ||
|
||
start_memcached | ||
python manage.py runserver 0.0.0.0:8000 | ||
case $1 in | ||
"--uwsgi") | ||
shift | ||
start_uwsgi $@ | ||
;; | ||
"--fcgi") | ||
shift | ||
start_fcgi $@ | ||
;; | ||
"--pypy") | ||
PYTHON=pypy | ||
shift | ||
start_normal $@ | ||
;; | ||
*) | ||
PYTHON=python | ||
start_normal $@ | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#! /bin/bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
OS=$(uname -s) | ||
case $OS in | ||
"Darwin") | ||
GROUP=www | ||
;; | ||
"Linux") | ||
GROUP=www-data | ||
;; | ||
*) | ||
echo "Unknown OS" | ||
;; | ||
esac | ||
|
||
sudo nginx \ | ||
-c $DIR/.nginx_conf \ | ||
-g "pid /tmp/CodeStreak.nginx.pid; user $USER $GROUP;" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#! /bin/bash | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" | ||
|
||
sudo nginx \ | ||
-s stop \ | ||
-g "pid /tmp/CodeStreak.nginx.pid;" |