Updated production environment:

+ Install script now creates some needed folders and files for the app user
+ Updated nginx.conf file
+ The nginx.conf file is copied to the $HOME/conf folder
+ git describe output is stored.
+ Added raven to requirements and configuration is added to the local_settings file
+ Added unicorn to requirements and configuration is added to the local_settings file
This commit is contained in:
Felipe Martín 2013-05-23 12:00:50 +02:00
parent e39c3fec79
commit 36c843249a
5 changed files with 37 additions and 4 deletions

View File

@ -31,6 +31,10 @@ CONFIG_FILES = [
'%s/config/production/local_settings.py' % GIT_DOWNLOAD_DIR, '%s/config/production/local_settings.py' % GIT_DOWNLOAD_DIR,
'%s/herobrine/local_settings.py' % APP_DIRECTORY '%s/herobrine/local_settings.py' % APP_DIRECTORY
), ),
(
'%s/config/production/nginx.conf' % GIT_DOWNLOAD_DIR,
'./conf/nginx.conf'
),
] ]
FIXTURES = [ FIXTURES = [
@ -213,6 +217,13 @@ else:
check_status(status) check_status(status)
sub('Storing current version:')
status = call('cd %s && git describe' % GIT_DOWNLOAD_DIR,
stdout=open('./conf/app_version', 'wb'),
stderr=open(os.devnull, 'wb'),
shell=True)
check_status(status)
# =========== CHECK SCRIPT UPDATE ================== # =========== CHECK SCRIPT UPDATE ==================
title('Checking if deploy script is updated on repository') title('Checking if deploy script is updated on repository')
actual_size = os.stat('./deploy.py').st_size actual_size = os.stat('./deploy.py').st_size
@ -382,7 +393,7 @@ if PREPROCESSORS['less']['items']:
check_status(status, words=[os.path.basename(path_to), 'failed']) check_status(status, words=[os.path.basename(path_to), 'failed'])
title('Collecting all staticfiles') title('Collecting all staticfiles')
sub('manage.py collectstatic') sub('manage.py ollectstatic:')
status = call( status = call(
'source %s/bin/activate && python %s/manage.py collectstatic --noinput' % ( 'source %s/bin/activate && python %s/manage.py collectstatic --noinput' % (
VIRTUALENV_PATH, VIRTUALENV_PATH,
@ -392,8 +403,8 @@ status = call(
shell=True, executable='/bin/bash' shell=True, executable='/bin/bash'
) )
check_status(status) check_status(status)
# ================ SERVER =======================
# ================ SERVER =======================
print("") print("")
success('Finished!') success('Finished!')

View File

@ -34,9 +34,16 @@ npm install -g coffee-script
npm install -g uglify-js npm install -g uglify-js
npm install -g less npm install -g less
echo "=> Creating user app and its home folder" echo "=> Creating user APP with its requirements"
# Create site user # Create site user
useradd app useradd app
mkdir /home/app mkdir /home/app
chown app:app /home/app chown app:app /home/app
echo "[REMEMBER!] create ssh keypair for the server." su - app -c "mkdir conf"
su - app -c "touch ./conf/app_version"
su - app -c "touch .environment"
su - app -c "echo 'source .environment' > .bash_profile"
# Reminders
echo "[REMEMBER!]"
echo " - Create ssh keypair for the server."

View File

@ -30,3 +30,13 @@ STATIC_URL = '/static/'
# Mediafiles # Mediafiles
MEDIA_ROOT = 'media' MEDIA_ROOT = 'media'
MEDIA_URL = '/media/' MEDIA_URL = '/media/'
# Sentry
RAVEN_CONFIG = {
'dsn': 'http://809b0824b821462db7902f96cf5ad2c9:bf82b9625be84d9fb2f2a15af1009176@sentry.fmartingr.com/4',
}
INSTALLED_APPS = INSTALLED_APPS + (
'raven.contrib.django.raven_compat',
'gunicorn'
)

View File

@ -14,5 +14,8 @@ server {
# pass requests for dynamic content to rails/turbogears/zope, et al # pass requests for dynamic content to rails/turbogears/zope, et al
location / { location / {
proxy_pass http://127.0.0.1:8000; proxy_pass http://127.0.0.1:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
} }
} }

View File

@ -1,2 +1,4 @@
psycopg2==2.5 psycopg2==2.5
raven==3.3.7
gunicorn==0.17.4
-r ../requirements.pip -r ../requirements.pip