-
Notifications
You must be signed in to change notification settings - Fork 4
making sure that media on the development environment is not served from outside the environment. #4
base: master
Are you sure you want to change the base?
making sure that media on the development environment is not served from outside the environment. #4
Changes from all commits
5d7e056
76ea576
c764234
3feee15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
syntax: regex | ||
^media/ | ||
^static/ | ||
^.gitignore$ | ||
^.hg/ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,6 @@ | |
*.swp | ||
*.un~ | ||
*.db | ||
static_root/ | ||
/media/* | ||
/static_root/* | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from fabric.api import local, env | ||
from fabric.api import local, env, require | ||
|
||
def production(): | ||
env['epioapp'] = # production epio instance name | ||
|
@@ -7,15 +7,20 @@ def staging(): | |
env['epioapp'] = # staging epio instance | ||
|
||
def epio(commandstring): | ||
local("epio {0} -a {1}".format( | ||
commandstring, | ||
env['epioapp'])) | ||
require('epioapp', provided_by=['production','staging']) | ||
from os import path | ||
with lcd(path.dirname(__file__)): | ||
local("epio {0} -a {1}".format( | ||
commandstring, | ||
env['epioapp'])) | ||
|
||
def deploy(): | ||
""" An example deploy workflow """ | ||
local("./manage.py collectstatic") | ||
epio('suspend') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is there a good reason to suspend-deploy-resume? Until now I've just deployed to a running instance with no issues. At some point the backend restarts the instance once the deploy is complete. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a few seconds in between deploying the code, running the migrations and flushing the cache that the app is in an intermediate state and can throw errors or otherwise get in a tissy. Suspend and resume guards ensure that the deploy happens atomically. I have spoken to Andrew Godwin on this and he plans to support a maintennance suspension mode specifically for this purpose. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Spoke with Andrew about this. Basically, we should support deploy with and without suspending as two separate management commands. Deploying new code should suspend and resume to take advantage of the maintenance mode, deploying new CSS shouldn't interfere with a running webapp like that. Bottom line, there should be two management commands, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about: deploy(suspend=True): There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay, that sounds like a reasonable way to do it. +1. |
||
local('./manage.py "collectstatic --noinput"') | ||
epio('upload') | ||
epio('django syncdb') | ||
epio('django migrate') | ||
epio('django epio_flush_cache') | ||
epio('resume') | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,11 @@ | |
USE_I18N = True | ||
USE_L10N = True | ||
|
||
MEDIA_ROOT = PROJECT_DIR.parent.child('data') | ||
MEDIA_ROOT = PROJECT_DIR.child('media') | ||
MEDIA_URL = '/media/' | ||
|
||
STATIC_ROOT = PROJECT_DIR.child('static_root') | ||
STATIC_ROOT = PROJECT_DIR.child('static-root') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the change from underscore to hyphen here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. because it looks neater. Easier to read. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this case, I think legibility is a matter of personal preference. I use underscores, not dashes. -1 on this change. |
||
STATIC_URL = '/static/' | ||
|
||
STATICFILES_DIRS = ( | ||
str(PROJECT_DIR.child('static')), | ||
) | ||
|
@@ -87,4 +87,4 @@ | |
'propagate': True, | ||
}, | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
from __future__ import absolute_import | ||
from .base import * | ||
|
||
MEDIA_ROOT = PROJECT_DIR.parent.child('data') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we're adding this line here anyways, might as well do it right: the value for |
||
STATIC_ROOT = PROJECT_DIR.child('static-root') | ||
|
||
from bundle_config import config | ||
DATABASES = { | ||
'default': { | ||
|
@@ -15,9 +18,7 @@ | |
CACHES = { | ||
'default': { | ||
'BACKEND': 'redis_cache.RedisCache', | ||
'LOCATION': '{host}:{port}'.format( | ||
host=config['redis']['host'], | ||
port=config['redis']['port']), | ||
'LOCATION': '%(host)s:%(port)s' % config['redis'], | ||
'OPTIONS': { | ||
'PASSWORD': config['redis']['password'], | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why add .gitignore to .epioignore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because .epioignore is for everything that should not be transmitted to the bundler. This includes VCS metadata.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1.