1. 程式人生 > >Passenger簡介

Passenger簡介

圖片 passenger 運行 uic default har pps 自動 number

https://www.phusionpassenger.com/docs/tutorials/what_is_passenger/


What is Passenger?

一個開源的web程序服務。它除了HTTP請求,管理進程和資源,能夠administration, monitoring,並進行問題診斷。

技術分享圖片

容易使用,讓產品的部署變得容易和scalable(

if a piece of computer hardwareor software is scalable, it continues to work well even if it is made bigger or connected to a larger number of other pieces of equipment

)即使程序逐步變大仍然運行良好。

它支持多種編程語言,Ruby, Python, Node。

它也能同時服務多個程序。

技術分享圖片

https://www.phusionpassenger.com/advantages (圖文簡介,很有趣,把自己比做航天器,功能強大,讓passengers輕松使用)

Fundamental concepts

關於Ruby的。

Passenger and "rails server"

ROR框架提供一個內建的服務器工具, 讓可以使用rails server命令。但"rails server"本身不是一個服務器程序,而是一個小的wrapper,在一個應付程序服務內,發射你的app。

這就是人們不使用"rails server"在production的原因。他們使用一個應用程序服務an application server,比如Passenger,直接地。

"rails server" uses Puma by default as of Rails 5.

如果你增加Passenger到你的Gemfile(點擊看step by step), “rails server”會發射Passenger替代Puma。當然也可以直接選擇launch Passenger 。

How Passenger fits in the stack

當不是web app到production, 有各種類型的組件be involved(參與)

你可能聽說過Unicorn, Puma, Nginx, Apache and Capistrano.

Passenger當和其他組件合作時,會取代一些組件。Passenger replaces some components, while collaborating with other components.

In a typical production stack, one would use Nginx or Apache as the web server, Passenger as application server, and Capistrano as release automation tool. Passenger integrates with Nginx or Apache and manages the application and its resources.

在一個典型的產品堆,一個將使用Nginx/Apache作為web服務器, Passenger作為app服務器,Capistrano作為版本釋放的自動化工具。Passenger集成了Nginx/Apache並管理app和它的resources.

技術分享圖片

需要聯合使用Nginx or Apache的原因:(2個)

web servers. 提供HTTP transaction 處理和服務靜態的文件。

1.但是,它們不是Ruby app 服務器,不能直接的跑Ruby app.

所以需要聯合一個app 服務器,例如Passenger.

Application servers make it possible for Ruby apps to speak HTTP.

app服務器可以讓Ruby apps來說HTTP。Ruby apps(如Rails)它們自身做不到這點。

2.另一方面,app server明顯不能像Nginx/Apache那樣高效的處理HTTP請求

魔鬼在細節裏:

Nginx/Apache更善於處理I/O安全, HTTP並發管理, 超時連接等等!!!

因此,在產品環境內,程序服務器app server和Nginx/Apache聯合起來被使用。

Capistrano

一個應用程序 release automation tool! (釋放版本的自動化工具)。

當釋放一個你的web application的新版本時,會有actions需要被執行performed, 如uploading你的程序代碼到服務器, 運行一條命令來安裝你的gem bundle,重啟進程等等。Capistrano會自動化這些actions.

Capistrano不能取代一個server來提供HTTP transaction handling, 所以它聯合app servers和web servers。

Unicorn and Puma

可選的app servers。被Passenger代替了。

因為,Passenger讓使用更方便,和其他組件集成,自動管理和問題診斷diagnosis.

Passenger簡介