【发布时间】:2014-03-14 23:41:41
【问题描述】:
遇到一个意外问题,我最近尝试在 Heroku 上为应用运行 collectstatic 无限期超时:
Running `python manage.py collectstatic` attached to terminal... up, run.6250
/app/.heroku/python/lib/python2.7/site-packages/dotenv.py:16: UserWarning: not reading .env - it doesn't exist.
warnings.warn("not reading %s - it doesn't exist." % dotenv)
You have requested to collect static files at the destination
location as specified in your settings.
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
我输入“是”后,它挂起并超时,没有错误。当我附加 --dry-run --noinput 时也会发生同样的事情。我的 env.txt 文件包括
AWS_ACCESS_KEY
AWS_SECRET_ACCESS_KEY
AWS_QUERYSTRING_AUTH = False
我很困惑,因为我的代码没有任何变化,而且我之前已经成功地用这个应用程序运行了一个 collectstatic。
应用程序正在使用 django-storage 而不是 S3-boto。这是我的设置:
if DEBUG:
#dev storage using local
...
else:
# Production AWS S3
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
AVATAR_STORAGE_DIR = 'avatars/'
AWS_ACCESS_KEY_ID = env('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = env('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = env('AWS_STORAGE_BUCKET_NAME')
AWS_QUERYSTRING_AUTH = env('AWS_QUERYSTRING_AUTH', False)
AWS_PRELOAD_METADATA = True
STATIC_URL = 'http://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
MEDIA_URL = STATIC_URL
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'
所有 AWS 凭证都在 Heroku 配置中设置。 FWIW 我有
heroku labs:enable user-env-compile
启用
【问题讨论】:
标签: django heroku amazon-s3 static-files