迅风为Heroku部署
swiftwind-heroku的Python项目详细描述
有关详细信息,请参见Swiftwind project。
安装
环境变量:
# Should be setup automatically for you: SECRET_KEY='<a random value>' DATABASE_URL='postgres://user:pasword@host/dbname' # If you are using HTTPS you may wish to set the following yourself: HTTPS=1 # Will ensure site is served over HTTPS only HSTS_SECONDS=100000 # Will enable HSTS, and set the seconds timeout HSTS_INCLUDE_SUBDOMAINS=1 # Apply HSTS to subdomains
必需的Heroku插件
将为以下每个加载项设置免费计划:
- 博士后
- redis
多库
该项目还旨在支持部署到Dokku。为此,您需要:
- Postgres数据库(请参见Postgres Dokku plugin)
- redis服务器(Redis Dokku plugin)
您可以按如下方式部署:
# Get the repo git clone https://github.com/adamcharnock/swiftwind-heroku.git cd swiftwind-heroku # Create the app and set the config dokku apps:create swiftwind dokku config:set SECRET_KEY=random-string dokku postgres:create swiftwind dokku postgres:link swiftwind swiftwind dokku redis:create swiftwind dokku redis:link swiftwind swiftwind git push dokku dokku run ./manage.py migrate # Create a user you will use to login as dokku run ./manage.py createsuperuser # Set currency as you wish (GBP, EUR, USD etc) dokku run ./manage.py swiftwind_create_accounts --currency USD
故障排除
django在部署到生产环境中时不会显示非常有用的错误,这是有原因的。 但是,您可以启用调试输出来帮助修复您可能看到的任何服务器错误 在浏览器中访问Sentry时:
heroku config:set DEBUG=1 heroku config:unset DEBUG
您还可以查看服务器日志:
heroku logs -t
注意:您可以在上述任何命令中将heroku替换为dokku。