[英]How to deploy a Pyramid app to DotCloud?
I have a Pyramid webapp with a Postgres database, and I'm using git for version control. 我有一个带有Postgres数据库的Pyramid Webapp,并且我正在使用git进行版本控制。
This is how my files are structured: 这是我的文件的结构:
myapp/
|----dotcloud.yml
|----env/ # virtualenv
|----MyProject/
|
|----production.ini
|----requirements.txt
|----myapp.sql
|----myapp.psql
|----wsgi.py
|----myproject
|
|----scripts/
|----static/
|----templates/
|----__init__.py
|----views.py
|----models.py
This is my dotcloud.yml: 这是我的dotcloud.yml:
www:
type: python
config:
python_version: v2.7
approot: home/home/myapp
db:
type: postgresql
This is my wsgi.py
: 这是我的
wsgi.py
:
from pyramid.paster import get_app, setup_logging
ini.ath = '.../myproject/production.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')
This is my (simplified) __init__.py
: 这是我的(简化)
__init__.py
:
def main(global_config, **settings):
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
config = Configurator(...)
config.add_static_view('static', 'static', cache_max_age=3600)
config.add_route('index', '/')
# other routes...
config.scan()
return config.make_wsgi_app()
I've read the official documentation and the third-party documentation to get to this point but there must be something I'm not doing right. 到目前为止,我已经阅读了官方文档和第三方文档 ,但是肯定有些事情我做得不对。 It's my first time deploying a webapp, and running my app locally still works.
这是我第一次部署Web应用程序,并且仍然可以在本地运行我的应用程序。
In MyProject/ (where the dotcloud.yml
file resides) I did dotcloud create mydomainname
, dotcloud connect mydomainname
and then dotcloud push
. 在MyProject
dotcloud.yml
文件所在的位置)中,我做了dotcloud create mydomainname
, dotcloud connect mydomainname
,然后dotcloud push
。 But I'm getting an internal server error. 但是我收到一个内部服务器错误。 What am I doing wrong?
我究竟做错了什么?
Also, the documentation says that if I'm using git, I must state that explicitly when I use dotcloud create
or dotcloud connect
, but what is the exact command? 此外,文档还指出,如果我使用的是git,则必须在使用
dotcloud create
或dotcloud connect
时明确dotcloud connect
,但确切的命令是什么?
EDIT: Before moving to DotCloud, I tried to use DigitalOcean, and had some problems when using pip to install the dependencies in requirements.txt. 编辑:在迁移到DotCloud之前,我尝试使用DigitalOcean,并且在使用pip在Requirements.txt中安装依赖项时遇到了一些问题。 I had to do a git clone separately on the CLI so that I could enter my username and password, and I also had to install psycopg2 manually.
我必须在CLI上单独进行git clone,以便输入用户名和密码,并且还必须手动安装psycopg2。 Could this be one of the problems here too?
这可能也是这里的问题之一吗? If so, how can I fix it?
如果是这样,我该如何解决?
There are several things you should try changing. 您应该尝试更改几件事。 First, do not push your virtualenv directory (
env
). 首先,不要推送您的virtualenv目录(
env
)。 The dotCloud builder will create another virtualenv based on your requirements.txt
. dotCloud构建器将根据您的
requirements.txt
创建另一个virtualenv。 One way to avoid pushing your env directory would be to move dotcloud.yml
to MyProject
. 避免推你的env目录的一种方法是移动
dotcloud.yml
到MyProject
。 You seem to think that is where it is ( "In MyProject/ (where the dotcloud.yml file resides)" ) but that is not what your file tree says. 您似乎认为这就是它所在的位置( “在MyProject /(dotcloud.yml文件所在的位置)” ),但这不是文件树所说的。
Then, do the dotcloud connect
or dotcloud create
in MyProject
, as you stated. 然后,按照您所说的在
MyProject
进行dotcloud connect
或dotcloud create
。
You should remove the approot
line from your dotcloud.yml. 您应该从dotcloud.yml中删除
approot
行。 Allow approot
to go to its default, the current directory. 允许
approot
进入默认目录,即当前目录。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.