Skip to Content
Python高级编程(第2版)
book

Python高级编程(第2版)

by Posts & Telecom Press, Michał Jaworski, Tarek Ziadé
February 2024
Intermediate to advanced
423 pages
6h 9m
Chinese
Packt Publishing
Content preview from Python高级编程(第2版)

第6章 部署代码

即使是完美的代码(如果存在的话),如果它没有运行也是没有用的。所以为了实现某个目的,我们需要在目标机器(计算机)上安装我们的代码并执行。使特定版本的应用或服务对最终用户可用的过程叫作部署(deployment)。

对于桌面应用而言,这似乎很简单——提供一个可下载的软件包即可,必要时提供可选的安装器。用户负责下载并在环境中安装。你的责任是使这个过程尽可能简单方便。正确的打包仍然不是一项简单的任务,但上一章已经介绍过一些工具。

令人惊讶的是,如果你的代码本身不是一个产品,那么事情会变得更加复杂。如果你的应用仅提供向用户销售的服务,那么你有责任在自己的基础设施上运行它。这个场景对于web应用或任何“X即服务”的产品来说是非常典型的。在这种情况下,代码被部署到远程机器上,开发人员通常几乎无法实体访问这些机器。如果你已经是云计算服务(例如亚马逊网络服务(AWS或Heroku)的用户的话,则更是如此。

本章我们重点关注将代码部署到远程主机方面的内容,因为Python在构建各种与Web相关的服务和产品的领域非常流行。虽然这门语言具有很高的可移植性,但却无法保证代码能够轻松部署。最重要的是应用的构建方式,以及将其部署到目标环境中所使用的流程。因此本章将重点讨论以下主题:

  • 将代码部署到远程环境的主要挑战是什么?
  • 在Python中如何构建易于部署的应用?
  • 如何在不停机的情况下重新加载Web服务?
  • 在代码部署中如何利用Python打包生态系统?
  • 如何正确地监视并检测远程运行的代码?

无痛部署的主要要求是确保构建应用的过程尽可能简单和流畅。这主要是清除障碍并鼓励成熟的做法。在有些组织中,只有特定的人负责开发(开发团队,Dev),而不同的人负责部署和维护执行环境(运营团队,Ops),那么遵守这些常见做法就特别重要。 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Hadoop实际解决方案手册

Hadoop实际解决方案手册

Posts & Telecom Press, JONATHAN OWENS, Lentz Jon, Femiano Brian
TensorFlow机器学习

TensorFlow机器学习

Posts & Telecom Press, Quan Hua, Shams Ul Azeem, Saif Ahmed
Python和NLTK实现自然语言处理

Python和NLTK实现自然语言处理

Posts & Telecom Press, Nitin Hardeniya
Kafka权威指南(第2版)

Kafka权威指南(第2版)

Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty

Publisher Resources

ISBN: 9781835887745