本文介绍了为生产准备金字塔应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当我接近 Web 项目的生产阶段时,我一直想知道如何部署金字塔应用程序.在文档中,它说使用 ../bin/python setup.py develop 将应用程序置于 development mode.是否有另一种设计用于生产的模式.或者我只是使用 ../bin/python setup.py install.

So as I near the production phase of my web project, I've been wondering how exactly to deploy a pyramid app. In the docs, it says to use ../bin/python setup.py develop to put the app in development mode. Is there another mode that is designed for production. Or do I just use ../bin/python setup.py install.

推荐答案

python setup.py developpython setup.py install 之间的巨大区别.install 是否会在您的 site-packages 目录中安装包.develop 会安装一个 egg-link 指向开发目录.

Well the big difference between python setup.py develop and python setup.py install. Is that install will install the package in your site-packages directory. While develop will install an egg-link that point to the directory for development.

所以是的,您可以在技术上同时使用这两种方法.但是根据您如何完成项目,在 site-package 中安装可能是一个坏主意.

So yeah you can technically use both method. But depending on how you did your project, installing in site-package might be a bad idea.

为什么?FileUpload 或您的应用程序可能生成的任何内容,例如动态文件等...如果您的应用程序不使用配置文件来查找保存文件的位置.安装您的应用并运行您的应用可能会尝试在您的 site-packages 目录中写入文件.

Why? FileUpload or anything your app might generate like dynamic files etc... If your app doesn't use config files to find where to save your files. Installing your app and running your app may try to write file in your site-packages directory.

换句话说,您必须确保可以使用配置文件定位可能生成的所有文件和目录等.

In other words, you have to make sure that all files and directories that may be generated, etc can be located using config files.

那么如果在configs中指出所有dynamic目录,那么安装是好的...

Then if all dynamic directories are pointed out in the configs, then installing is good...

您所要做的就是创建一个包含 production.ini 文件的文件夹并运行 pserve production.ini.

All you'll have to do is create a folder with a production.ini file and run pserve production.ini.

代码可以通过这种方式保存在您的组件上的任何位置,您也可以使用 uWSGI 或任何其他您喜欢的 WSGI 服务器.

Code can be saved anywhere on your comp that way and you can also use uWSGI or any other WSGI server you like.

我认为安装代码并不是一件坏事,从应用程序中获取数据是一件好事.

I think installing the code isn't a bad thing, and having data appart from the application is a good thing.

我猜它在部署方面有一些优势.

It has some advantage for deployment I guess.

这篇关于为生产准备金字塔应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-13 04:01