Python 虚拟主机:为什么需要重启服务器? [英] Python web hosting: Why are server restarts necessary?

查看:23
本文介绍了Python 虚拟主机:为什么需要重启服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们目前在我们的服务器上为数百个小型 PHP 站点运行一个小型共享托管服务.我们也想提供 Python 支持,但至少从我们最初的研究来看,每次更改源代码后似乎都需要重新启动服务器.

We currently run a small shared hosting service for a couple of hundred small PHP sites on our servers. We'd like to offer Python support too, but from our initial research at least, a server restart seems to be required after each source code change.

真的是这样吗?如果是这样,我们将无法提供 Python 托管支持.让我们的客户能够上传文件很容易,但我们不能让他们重新启动(共享)服务器进程!

Is this really the case? If so, we're just not going to be able to offer Python hosting support. Giving our clients the ability to upload files is easy, but we can't have them restart the (shared) server process!

PHP 很简单 -- 您上传文件的新版本,然后运行新版本.

PHP is easy -- you upload a new version of a file, the new version is run.

我非常尊重 Python 语言和社区,因此很难相信更新站点代码真的需要如此疯狂的过程.请告诉我我错了!:-)

I've a lot of respect for the Python language and community, so find it hard to believe that it really requires such a crazy process to update a site's code. Please tell me I'm wrong! :-)

推荐答案

Python 是一种编译语言;编译后的字节码由 Python 进程缓存以备后用,以提高性能.默认情况下,PHP 是被解释的.这是可用性和速度之间的权衡.

Python is a compiled language; the compiled byte code is cached by the Python process for later use, to improve performance. PHP, by default, is interpreted. It's a tradeoff between usability and speed.

如果您使用的是标准 WSGI 模块,例如 Apache 的 mod_wsgi,那么您不必重新启动服务器——只需触摸 .wsgi 文件并且代码将被重新加载.如果您正在使用一些不支持 WSGI 的奇怪服务器,那么您在某种程度上是在自己的可用性方面.

If you're using a standard WSGI module, such as Apache's mod_wsgi, then you don't have to restart the server -- just touch the .wsgi file and the code will be reloaded. If you're using some weird server which doesn't support WSGI, you're sort of on your own usability-wise.

这篇关于Python 虚拟主机:为什么需要重启服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆