SlideShare a Scribd company logo
PASSENGER

GENERIC LANGUAGE SUPPORT
2018 live stream
TABLE OF CONTENTS
1. Why?
2. UX goal
3. Passenger architecture
4. Implementation plan
5. Coding!
Questions?

Comments?
Enter them in the chat

(or post on Github)
➤ Bring all the good stuff of Passenger
to the whole world
➤ Standardization
➤ Onboard team members faster
➤ Streamline procedures
➤ Reduce inconsistencies
➤ Share and retain operational knowledge
➤ Focus
➤ Write less code
➤ Reduce infrastructure complexity
➤ Automate the boring details
➤ Focus on your core business
Why GLS?
UX?
Ask for a

command string!
Like Heroku's Procfile
USER EXPERIENCE (1/2)
server	{	
				listen	80;	
				server_name	foo.com;	
				root	/webapps/fooapp/public;	
				passenger_enabled	on;	
				passenger_app_start_command	'./fooexe	--port=$PORT';	
}
USER EXPERIENCE (2/2)
#	Passengerfile.json	
{	"app_start_command":	"./fooexe	--port=$PORT"	}	
#	Nginx	config	
server	{	
				listen	80;	
				server_name	foo.com;	
				root	/webapps/fooapp/public;	
				passenger_enabled	on;	
				#	Look,	no	passenger_app_start_command!	
}
Passenger architecture 101
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
We need to

modify these!
Passenger agent
Config
Core
ApiServer Controller
main request handling server
Security
Update
Checker
Telemetry
Collector
Contains most Passenger business logic. Manages processes, routes requests.
Config
ApiServerCoreWatcher
InstanceDir
Toucher
Watchdog
Starts and supervises the Core.
ApplicationPool
Pool
main subsystem
interface
Options
collection of app config;
collection of parameters for
a get() call
Session
represents a single
request/response session
with a specific process
Group
represents an app; a
collection of
processes
Process
represents a single
app process
Socket
represents a server
socket endpoint that
a process listens on
Context
global subsystem
configuration
Public
interface
Internals
Abstracts application process spawning and management logic into a simple API. Keeps track of
processes and related statistics.
SpawnEnvSetupper
Exec wrapper used by
SpawningKit.
Sets up the process environment, then
executes the actual application
command.
ExecHelper
executes a command as a
specific user, similar to sudo
Utilities
SystemMetrics
prints various system
metrics
TempDirToucher
touches everything in a dir
periodically to prevent
deletion by /tmp cleaners
Context
global subsystem
configuration
SpawningKit
Low-level subsystem specialized in spawning application processes.
Factory
given a spawn method and language name,
creates appropriate Spawner object
Direct
Spawner
implements "direct"
spawn method
Smart
Spawner
implements "smart"
spawn method
<<abstract>>
Spawner
main subsystem interface
Result
info about a spawned process; returned by
Spawner
Error
Renderer
given a spawn
exception, generates
HTML error page
Exceptions
relevant exception
classes
User
Switching
Rules
figures out which
user an app
should run as
HandshakePrepare
implements the preparation
phase of the spawn flow
Config
config of a single
spawn operation
BackgroundIO
Capturer
runs in a thread & captures all
subprocess output in a string
Session
working state of a single spawn
operation
Public
interface
Internals
Spawning protocol logic Utilities
Passenger agent
Config
Core
ApiServer Controller
main request handling server
Security
Update
Checker
Telemetry
Collector
Contains most Passenger business logic. Manages processes, routes requests.
Config
ApiServerCoreWatcher
InstanceDir
Toucher
Watchdog
Starts and supervises the Core.
ApplicationPool
Pool
main subsystem
interface
Options
collection of app config;
collection of parameters for
a get() call
Session
represents a single
request/response session
with a specific process
Group
represents an app; a
collection of
processes
Process
represents a single
app process
Socket
represents a server
socket endpoint that
a process listens on
Context
global subsystem
configuration
Public
interface
Internals
Abstracts application process spawning and management logic into a simple API. Keeps track of
processes and related statistics.
SpawnEnvSetupper
Exec wrapper used by
SpawningKit.
Sets up the process environment, then
executes the actual application
command.
ExecHelper
executes a command as a
specific user, similar to sudo
Utilities
SystemMetrics
prints various system
metrics
TempDirToucher
touches everything in a dir
periodically to prevent
deletion by /tmp cleaners
Context
global subsystem
configuration
SpawningKit
Low-level subsystem specialized in spawning application processes.
Factory
given a spawn method and language name,
creates appropriate Spawner object
Direct
Spawner
implements "direct"
spawn method
Smart
Spawner
implements "smart"
spawn method
<<abstract>>
Spawner
main subsystem interface
Result
info about a spawned process; returned by
Spawner
Error
Renderer
given a spawn
exception, generates
HTML error page
Exceptions
relevant exception
classes
User
Switching
Rules
figures out which
user an app
should run as
HandshakePrepare
implements the preparation
phase of the spawn flow
Config
config of a single
spawn operation
BackgroundIO
Capturer
runs in a thread & captures all
subprocess output in a string
Session
working state of a single spawn
operation
Public
interface
Internals
Spawning protocol logic Utilities
Three

layers!
Config
Core
ApiServer Controller
main request handling server
Security
Update
Checker
Telemetry
Collector
Contains most Passenger business logic. Manages processes, routes requests.
ApplicationPool
Pool
main subsystem
interface
Options
collection of app config;
collection of parameters for
a get() call
Session
represents a single
request/response session
with a specific process
Group
represents an app; a
collection of
processes
Process
represents a single
app process
Socket
represents a server
socket endpoint that
a process listens on
Context
global subsystem
configuration
Public
interface
Internals
Abstracts application process spawning and management logic into a simple API. Keeps track of
processes and related statistics.
Passenger agent
Config
Core
ApiServer Controller
main request handling server
Security
Update
Checker
Telemetry
Collector
Contains most Passenger business logic. Manages processes, routes requests.
ApplicationPool
Pool
main subsystem
interface
Options
collection of app config;
collection of parameters for
a get() call
Session
represents a single
request/response session
with a specific process
Group
represents an app; a
collection of
processes
Process
represents a single
app process
Socket
represents a server
socket endpoint that
a process listens on
Context
global subsystem
configuration
Public
interface
Internals
Abstracts application process spawning and management logic into a simple API. Keeps track of
processes and related statistics.
Passenger agent
Context
global subsystem
configuration
SpawningKit
Low-level subsystem specialized in spawning application processes.
Factory
given a spawn method and language name,
creates appropriate Spawner object
Direct
Spawner
implements "direct"
spawn method
Smart
Spawner
implements "smart"
spawn method
<<abstract>>
Spawner
main subsystem interface
Result
info about a spawned process; returned by
Spawner
Error
Renderer
given a spawn
exception, generates
HTML error page
Exceptions
relevant exception
classes
User
Switching
Rules
figures out which
user an app
should run as
HandshakePrepare
implements the preparation
phase of the spawn flow
HandshakePerform
implements the waiting &
response phase of the spawn
flow
Journey
keeps track of
spawn operation
progress
Config
config of a single
spawn operation
PipeWatcher
runs in a thread & logs all
subprocess output
BackgroundIO
Capturer
runs in a thread & captures all
subprocess output in a string
Session
working state of a single spawn
operation
WorkDir
temp dir for a single spawn
operation, used to communicate
with the subprocess
Public
interface
Internals
Spawning protocol logic Utilities
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Passenger 6 generic language support presentation
Detailed

implementation

plan
5.3.0
Foundation already laid in
Implemented generic spawn flow
SpawningKit::
DirectSpawner
Language wrapper
Ruby: rack-loader
Python: wsgi-loader
Node.js: nodejs-loader
HandshakePrepare:
- create work dir (temp dir)
- dump config into a file in work dir (JSON)
create new process
- load config from work dir
- load app (e.g. config.ru, index.js)
- setup other behavior (e.g. stats collection)
- setup internal server
finish signal,
internal server address
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
auto-supported apps
SpawningKit::
DirectSpawner
Language wrapper
Ruby: rack-loader
Python: wsgi-loader
Node.js: nodejs-loader
HandshakePrepare:
- create work dir (temp dir)
- dump config into a file in work dir (JSON)
create new process
- load config from work dir
- load app (e.g. config.ru, index.js)
- setup other behavior (e.g. stats collection)
- setup internal server
finish signal,
internal server address
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
auto-supported apps
SpawningKit::
DirectSpawner
Language wrapper
Ruby: rack-loader
Python: wsgi-loader
Node.js: nodejs-loader
HandshakePrepare:
- create work dir (temp dir)
- dump config into a file in work dir (JSON)
create new process
- load config from work dir
- load app (e.g. config.ru, index.js)
- setup other behavior (e.g. stats collection)
- setup internal server
finish signal,
internal server address
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
auto-supported apps
SpawningKit::
DirectSpawner
Language wrapper
Ruby: rack-loader
Python: wsgi-loader
Node.js: nodejs-loader
HandshakePrepare:
- create work dir (temp dir)
- dump config into a file in work dir (JSON)
create new process
- load config from work dir
- load app (e.g. config.ru, index.js)
- setup other behavior (e.g. stats collection)
- setup internal server
finish signal,
internal server address
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
auto-supported apps
SpawningKit::
DirectSpawner
Language wrapper
Ruby: rack-loader
Python: wsgi-loader
Node.js: nodejs-loader
HandshakePrepare:
- create work dir (temp dir)
- dump config into a file in work dir (JSON)
create new process
- load config from work dir
- load app (e.g. config.ru, index.js)
- setup other behavior (e.g. stats collection)
- setup internal server
finish signal,
internal server address
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
auto-supported apps
SpawningKit::
DirectSpawner
Language wrapper
Ruby: rack-loader
Python: wsgi-loader
Node.js: nodejs-loader
HandshakePrepare:
- create work dir (temp dir)
- dump config into a file in work dir (JSON)
create new process
- load config from work dir
- load app (e.g. config.ru, index.js)
- setup other behavior (e.g. stats collection)
- setup internal server
finish signal,
internal server address
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
auto-supported apps
Normal flow [DONE]
Generic flow
Up next:
SpawningKit::
DirectSpawner
Application
HandshakePrepare:
- create work dir (temp dir)
- find free port
- dump config into a file in work dir (JSON)
create new process
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
generic apps
- initialization
- setup server socket
...
...
SpawningKit
notices that port
is now in use
Mechanism introduced in 5.3.0!

But not exposed to users.
SpawningKit::
DirectSpawner
Application
HandshakePrepare:
- create work dir (temp dir)
- find free port
- dump config into a file in work dir (JSON)
create new process
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
generic apps
- initialization
- setup server socket
...
...
SpawningKit
notices that port
is now in use
SpawningKit::
DirectSpawner
Application
HandshakePrepare:
- create work dir (temp dir)
- find free port
- dump config into a file in work dir (JSON)
create new process
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
generic apps
- initialization
- setup server socket
...
...
SpawningKit
notices that port
is now in use
SpawningKit::
DirectSpawner
Application
HandshakePrepare:
- create work dir (temp dir)
- find free port
- dump config into a file in work dir (JSON)
create new process
return process
info to caller
e.g. socket
address
Passenger application spawn flow (simplified):
generic apps
- initialization
- setup server socket
...
...
SpawningKit
notices that port
is now in use
Goal
Build the mechanisms needed
to activate
generic spawn flow
PLAN
Integration mode frontend
Core Controller
Core ApplicationPool
• Add user config (e.g. passenger_app_start_command)
• Process info from web server

-OR-

Perform our own autodetection (Standalone+builtin)
• Pass necessary info to ApplicationPool
Web server • Autodetect whether auto-supported or generic app
• Pass necessary info to Core Controller
• Modify Options class to support the new config options
• Properly configure SpawningKit
• Kill generic process upon shutdown
PLAN
Integration mode frontend
Core Controller
Core ApplicationPool
• Add user config (e.g. passenger_app_start_command)
• Process info from web server

-OR-

Perform our own autodetection (Standalone+builtin)
• Pass necessary info to ApplicationPool
Web server • Autodetect whether auto-supported or generic app
• Pass necessary info to Core Controller
• Modify Options class to support the new config options
• Properly configure SpawningKit
• Kill generic process upon shutdown
PLAN
Integration mode frontend
Core Controller
Core ApplicationPool
• Add user config (e.g. passenger_app_start_command)
• Process info from web server

-OR-

Perform our own autodetection (Standalone+builtin)
• Pass necessary info to ApplicationPool
Web server • Autodetect whether auto-supported or generic app
• Pass necessary info to Core Controller
• Modify Options class to support the new config options
• Properly configure SpawningKit
• Kill generic process upon shutdown
PLAN
Integration mode frontend
Core Controller
Core ApplicationPool
• Add user config (e.g. passenger_app_start_command)
• Process info from web server

-OR-

Perform our own autodetection (Standalone+builtin)
• Pass necessary info to ApplicationPool
Web server • Autodetect whether auto-supported or generic app
• Pass necessary info to Core Controller
• Modify Options class to support the new config options
• Properly configure SpawningKit
• Kill generic process upon shutdown
PLAN
Integration mode frontend
Core Controller
Core ApplicationPool
• Add user config (e.g. passenger_app_start_command)
• Process info from web server

-OR-

Perform our own autodetection (Standalone+builtin)
• Pass necessary info to ApplicationPool
Web server • Autodetect whether auto-supported or generic app
• Pass necessary info to Core Controller
• Modify Options class to support the new config options
• Properly configure SpawningKit
• Kill generic process upon shutdown
CONFIG TO ACTIVATE EACH SPAWNINGKIT FLOW
Generic
Auto-supported
genericApp	=	true	
startsUsingWrapper	irrelevant	
appType	irrelevant	
startupFile	irrelevant	
appStartCommand	=	[user-provided]
genericApp	=	false,	
startsUsingWrapper	=	true,	
appType	=	(ruby,python,nodejs),	
startupFile	=	(autodetected/user-provided),	
appStartCommand	=	(path	to	interpreter)	(path	to	wrapper)
Time to code!
Join the discussion on Github!
Thanks for watching!
https://github.com/phusion/passenger/issues/2135

More Related Content

PDF
Asynchronous Systems with Fn Flow
PPT
Gert Vanthienen Presentation
PPTX
Python at Facebook
PDF
Construire son JDK en 10 étapes
PDF
Lecture1: NGS Analysis on Beocat and an introduction to Perl programming for ...
PPT
Going serverless with Fn project, Fn Flow and Kubernetes
PDF
Fluentd meetup dive into fluent plugin (outdated)
PPTX
Internal Hive
Asynchronous Systems with Fn Flow
Gert Vanthienen Presentation
Python at Facebook
Construire son JDK en 10 étapes
Lecture1: NGS Analysis on Beocat and an introduction to Perl programming for ...
Going serverless with Fn project, Fn Flow and Kubernetes
Fluentd meetup dive into fluent plugin (outdated)
Internal Hive

What's hot (20)

PDF
Cfml features modern_coding
PPTX
PHP Conference - Phalcon hands-on
KEY
Crafting Beautiful CLI Applications in Ruby
PDF
Deployment Tactics
PPTX
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
PDF
DevOps in PHP environment
PPTX
Phalcon 2 - PHP Brazil Conference
PDF
Composer for Busy Developers - php|tek13
PDF
Fluentd v0.12 master guide
PPT
Composer - Package Management for PHP. Silver Bullet?
PDF
Composer the right way - SunshinePHP
PDF
upload test 1
PDF
Dependency management with Composer
PDF
Flashmedia gateway docs_quickstart
PPTX
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...
PDF
Phing: Building with PHP
KEY
Introducing Command Line Applications with Ruby
PDF
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
PDF
Zend Framework 1.8 workshop
PDF
Laravel 4 package development
Cfml features modern_coding
PHP Conference - Phalcon hands-on
Crafting Beautiful CLI Applications in Ruby
Deployment Tactics
Nagios Conference 2011 - Nathan Vonnahme - Integrating Nagios With Test Drive...
DevOps in PHP environment
Phalcon 2 - PHP Brazil Conference
Composer for Busy Developers - php|tek13
Fluentd v0.12 master guide
Composer - Package Management for PHP. Silver Bullet?
Composer the right way - SunshinePHP
upload test 1
Dependency management with Composer
Flashmedia gateway docs_quickstart
Codefresh + BlazeMeter Webinar: Continuous Testing for Containerized Applicat...
Phing: Building with PHP
Introducing Command Line Applications with Ruby
Automatic PHP 7 Compatibility Checking Using php7cc (and PHPCompatibility)
Zend Framework 1.8 workshop
Laravel 4 package development
Ad

Similar to Passenger 6 generic language support presentation (20)

PPTX
FailureEnrichers - Flink Meetup Bay Area.pptx
PPTX
Copper: A high performance workflow engine
PPT
Rapid java backend and api development for mobile devices
PPT
FMS Administration Seminar
PDF
Introduction to PowerShell
PPTX
Introduction to ASP.NET
PDF
GopherCon IL 2020 - Web Application Profiling 101
PPT
Php Asp Net Interoperability Rc Jao
PPT
Asp.net tips
PPT
nodejs_at_a_glance.ppt
PDF
Logging for Production Systems in The Container Era
PPTX
Building Web Apps with Express
PPT
nodejs_at_a_glance, understanding java script
PPTX
Intro to Node
PDF
NET Aspire - NET Conf IL 2024 - Tamir Dresher.pdf
PPT
sMash at May NYPHP UG
ODP
RichFaces - Testing on Mobile Devices
PPTX
Play framework : A Walkthrough
PPT
PDC Highlights
PPTX
My Saminar On Php
FailureEnrichers - Flink Meetup Bay Area.pptx
Copper: A high performance workflow engine
Rapid java backend and api development for mobile devices
FMS Administration Seminar
Introduction to PowerShell
Introduction to ASP.NET
GopherCon IL 2020 - Web Application Profiling 101
Php Asp Net Interoperability Rc Jao
Asp.net tips
nodejs_at_a_glance.ppt
Logging for Production Systems in The Container Era
Building Web Apps with Express
nodejs_at_a_glance, understanding java script
Intro to Node
NET Aspire - NET Conf IL 2024 - Tamir Dresher.pdf
sMash at May NYPHP UG
RichFaces - Testing on Mobile Devices
Play framework : A Walkthrough
PDC Highlights
My Saminar On Php
Ad

Recently uploaded (20)

PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PPTX
TLE Review Electricity (Electricity).pptx
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PPTX
A Presentation on Touch Screen Technology
PDF
Mushroom cultivation and it's methods.pdf
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
August Patch Tuesday
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
Chapter 5: Probability Theory and Statistics
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PPTX
A Presentation on Artificial Intelligence
PDF
Getting Started with Data Integration: FME Form 101
PDF
A comparative study of natural language inference in Swahili using monolingua...
PPTX
OMC Textile Division Presentation 2021.pptx
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
TLE Review Electricity (Electricity).pptx
SOPHOS-XG Firewall Administrator PPT.pptx
A Presentation on Touch Screen Technology
Mushroom cultivation and it's methods.pdf
Zenith AI: Advanced Artificial Intelligence
August Patch Tuesday
Assigned Numbers - 2025 - Bluetooth® Document
Chapter 5: Probability Theory and Statistics
A comparative analysis of optical character recognition models for extracting...
Univ-Connecticut-ChatGPT-Presentaion.pdf
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
ENT215_Completing-a-large-scale-migration-and-modernization-with-AWS.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Programs and apps: productivity, graphics, security and other tools
A Presentation on Artificial Intelligence
Getting Started with Data Integration: FME Form 101
A comparative study of natural language inference in Swahili using monolingua...
OMC Textile Division Presentation 2021.pptx

Passenger 6 generic language support presentation

  • 2. TABLE OF CONTENTS 1. Why? 2. UX goal 3. Passenger architecture 4. Implementation plan 5. Coding!
  • 3. Questions?
 Comments? Enter them in the chat
 (or post on Github)
  • 4. ➤ Bring all the good stuff of Passenger to the whole world ➤ Standardization ➤ Onboard team members faster ➤ Streamline procedures ➤ Reduce inconsistencies ➤ Share and retain operational knowledge ➤ Focus ➤ Write less code ➤ Reduce infrastructure complexity ➤ Automate the boring details ➤ Focus on your core business Why GLS?
  • 5. UX?
  • 6. Ask for a
 command string! Like Heroku's Procfile
  • 17. Passenger agent Config Core ApiServer Controller main request handling server Security Update Checker Telemetry Collector Contains most Passenger business logic. Manages processes, routes requests. Config ApiServerCoreWatcher InstanceDir Toucher Watchdog Starts and supervises the Core. ApplicationPool Pool main subsystem interface Options collection of app config; collection of parameters for a get() call Session represents a single request/response session with a specific process Group represents an app; a collection of processes Process represents a single app process Socket represents a server socket endpoint that a process listens on Context global subsystem configuration Public interface Internals Abstracts application process spawning and management logic into a simple API. Keeps track of processes and related statistics. SpawnEnvSetupper Exec wrapper used by SpawningKit. Sets up the process environment, then executes the actual application command. ExecHelper executes a command as a specific user, similar to sudo Utilities SystemMetrics prints various system metrics TempDirToucher touches everything in a dir periodically to prevent deletion by /tmp cleaners Context global subsystem configuration SpawningKit Low-level subsystem specialized in spawning application processes. Factory given a spawn method and language name, creates appropriate Spawner object Direct Spawner implements "direct" spawn method Smart Spawner implements "smart" spawn method <<abstract>> Spawner main subsystem interface Result info about a spawned process; returned by Spawner Error Renderer given a spawn exception, generates HTML error page Exceptions relevant exception classes User Switching Rules figures out which user an app should run as HandshakePrepare implements the preparation phase of the spawn flow Config config of a single spawn operation BackgroundIO Capturer runs in a thread & captures all subprocess output in a string Session working state of a single spawn operation Public interface Internals Spawning protocol logic Utilities
  • 18. Passenger agent Config Core ApiServer Controller main request handling server Security Update Checker Telemetry Collector Contains most Passenger business logic. Manages processes, routes requests. Config ApiServerCoreWatcher InstanceDir Toucher Watchdog Starts and supervises the Core. ApplicationPool Pool main subsystem interface Options collection of app config; collection of parameters for a get() call Session represents a single request/response session with a specific process Group represents an app; a collection of processes Process represents a single app process Socket represents a server socket endpoint that a process listens on Context global subsystem configuration Public interface Internals Abstracts application process spawning and management logic into a simple API. Keeps track of processes and related statistics. SpawnEnvSetupper Exec wrapper used by SpawningKit. Sets up the process environment, then executes the actual application command. ExecHelper executes a command as a specific user, similar to sudo Utilities SystemMetrics prints various system metrics TempDirToucher touches everything in a dir periodically to prevent deletion by /tmp cleaners Context global subsystem configuration SpawningKit Low-level subsystem specialized in spawning application processes. Factory given a spawn method and language name, creates appropriate Spawner object Direct Spawner implements "direct" spawn method Smart Spawner implements "smart" spawn method <<abstract>> Spawner main subsystem interface Result info about a spawned process; returned by Spawner Error Renderer given a spawn exception, generates HTML error page Exceptions relevant exception classes User Switching Rules figures out which user an app should run as HandshakePrepare implements the preparation phase of the spawn flow Config config of a single spawn operation BackgroundIO Capturer runs in a thread & captures all subprocess output in a string Session working state of a single spawn operation Public interface Internals Spawning protocol logic Utilities Three
 layers!
  • 19. Config Core ApiServer Controller main request handling server Security Update Checker Telemetry Collector Contains most Passenger business logic. Manages processes, routes requests. ApplicationPool Pool main subsystem interface Options collection of app config; collection of parameters for a get() call Session represents a single request/response session with a specific process Group represents an app; a collection of processes Process represents a single app process Socket represents a server socket endpoint that a process listens on Context global subsystem configuration Public interface Internals Abstracts application process spawning and management logic into a simple API. Keeps track of processes and related statistics. Passenger agent
  • 20. Config Core ApiServer Controller main request handling server Security Update Checker Telemetry Collector Contains most Passenger business logic. Manages processes, routes requests. ApplicationPool Pool main subsystem interface Options collection of app config; collection of parameters for a get() call Session represents a single request/response session with a specific process Group represents an app; a collection of processes Process represents a single app process Socket represents a server socket endpoint that a process listens on Context global subsystem configuration Public interface Internals Abstracts application process spawning and management logic into a simple API. Keeps track of processes and related statistics. Passenger agent
  • 21. Context global subsystem configuration SpawningKit Low-level subsystem specialized in spawning application processes. Factory given a spawn method and language name, creates appropriate Spawner object Direct Spawner implements "direct" spawn method Smart Spawner implements "smart" spawn method <<abstract>> Spawner main subsystem interface Result info about a spawned process; returned by Spawner Error Renderer given a spawn exception, generates HTML error page Exceptions relevant exception classes User Switching Rules figures out which user an app should run as HandshakePrepare implements the preparation phase of the spawn flow HandshakePerform implements the waiting & response phase of the spawn flow Journey keeps track of spawn operation progress Config config of a single spawn operation PipeWatcher runs in a thread & logs all subprocess output BackgroundIO Capturer runs in a thread & captures all subprocess output in a string Session working state of a single spawn operation WorkDir temp dir for a single spawn operation, used to communicate with the subprocess Public interface Internals Spawning protocol logic Utilities
  • 30. 5.3.0 Foundation already laid in Implemented generic spawn flow
  • 31. SpawningKit:: DirectSpawner Language wrapper Ruby: rack-loader Python: wsgi-loader Node.js: nodejs-loader HandshakePrepare: - create work dir (temp dir) - dump config into a file in work dir (JSON) create new process - load config from work dir - load app (e.g. config.ru, index.js) - setup other behavior (e.g. stats collection) - setup internal server finish signal, internal server address return process info to caller e.g. socket address Passenger application spawn flow (simplified): auto-supported apps
  • 32. SpawningKit:: DirectSpawner Language wrapper Ruby: rack-loader Python: wsgi-loader Node.js: nodejs-loader HandshakePrepare: - create work dir (temp dir) - dump config into a file in work dir (JSON) create new process - load config from work dir - load app (e.g. config.ru, index.js) - setup other behavior (e.g. stats collection) - setup internal server finish signal, internal server address return process info to caller e.g. socket address Passenger application spawn flow (simplified): auto-supported apps
  • 33. SpawningKit:: DirectSpawner Language wrapper Ruby: rack-loader Python: wsgi-loader Node.js: nodejs-loader HandshakePrepare: - create work dir (temp dir) - dump config into a file in work dir (JSON) create new process - load config from work dir - load app (e.g. config.ru, index.js) - setup other behavior (e.g. stats collection) - setup internal server finish signal, internal server address return process info to caller e.g. socket address Passenger application spawn flow (simplified): auto-supported apps
  • 34. SpawningKit:: DirectSpawner Language wrapper Ruby: rack-loader Python: wsgi-loader Node.js: nodejs-loader HandshakePrepare: - create work dir (temp dir) - dump config into a file in work dir (JSON) create new process - load config from work dir - load app (e.g. config.ru, index.js) - setup other behavior (e.g. stats collection) - setup internal server finish signal, internal server address return process info to caller e.g. socket address Passenger application spawn flow (simplified): auto-supported apps
  • 35. SpawningKit:: DirectSpawner Language wrapper Ruby: rack-loader Python: wsgi-loader Node.js: nodejs-loader HandshakePrepare: - create work dir (temp dir) - dump config into a file in work dir (JSON) create new process - load config from work dir - load app (e.g. config.ru, index.js) - setup other behavior (e.g. stats collection) - setup internal server finish signal, internal server address return process info to caller e.g. socket address Passenger application spawn flow (simplified): auto-supported apps
  • 36. SpawningKit:: DirectSpawner Language wrapper Ruby: rack-loader Python: wsgi-loader Node.js: nodejs-loader HandshakePrepare: - create work dir (temp dir) - dump config into a file in work dir (JSON) create new process - load config from work dir - load app (e.g. config.ru, index.js) - setup other behavior (e.g. stats collection) - setup internal server finish signal, internal server address return process info to caller e.g. socket address Passenger application spawn flow (simplified): auto-supported apps
  • 37. Normal flow [DONE] Generic flow Up next:
  • 38. SpawningKit:: DirectSpawner Application HandshakePrepare: - create work dir (temp dir) - find free port - dump config into a file in work dir (JSON) create new process return process info to caller e.g. socket address Passenger application spawn flow (simplified): generic apps - initialization - setup server socket ... ... SpawningKit notices that port is now in use Mechanism introduced in 5.3.0!
 But not exposed to users.
  • 39. SpawningKit:: DirectSpawner Application HandshakePrepare: - create work dir (temp dir) - find free port - dump config into a file in work dir (JSON) create new process return process info to caller e.g. socket address Passenger application spawn flow (simplified): generic apps - initialization - setup server socket ... ... SpawningKit notices that port is now in use
  • 40. SpawningKit:: DirectSpawner Application HandshakePrepare: - create work dir (temp dir) - find free port - dump config into a file in work dir (JSON) create new process return process info to caller e.g. socket address Passenger application spawn flow (simplified): generic apps - initialization - setup server socket ... ... SpawningKit notices that port is now in use
  • 41. SpawningKit:: DirectSpawner Application HandshakePrepare: - create work dir (temp dir) - find free port - dump config into a file in work dir (JSON) create new process return process info to caller e.g. socket address Passenger application spawn flow (simplified): generic apps - initialization - setup server socket ... ... SpawningKit notices that port is now in use
  • 42. Goal Build the mechanisms needed to activate generic spawn flow
  • 43. PLAN Integration mode frontend Core Controller Core ApplicationPool • Add user config (e.g. passenger_app_start_command) • Process info from web server
 -OR-
 Perform our own autodetection (Standalone+builtin) • Pass necessary info to ApplicationPool Web server • Autodetect whether auto-supported or generic app • Pass necessary info to Core Controller • Modify Options class to support the new config options • Properly configure SpawningKit • Kill generic process upon shutdown
  • 44. PLAN Integration mode frontend Core Controller Core ApplicationPool • Add user config (e.g. passenger_app_start_command) • Process info from web server
 -OR-
 Perform our own autodetection (Standalone+builtin) • Pass necessary info to ApplicationPool Web server • Autodetect whether auto-supported or generic app • Pass necessary info to Core Controller • Modify Options class to support the new config options • Properly configure SpawningKit • Kill generic process upon shutdown
  • 45. PLAN Integration mode frontend Core Controller Core ApplicationPool • Add user config (e.g. passenger_app_start_command) • Process info from web server
 -OR-
 Perform our own autodetection (Standalone+builtin) • Pass necessary info to ApplicationPool Web server • Autodetect whether auto-supported or generic app • Pass necessary info to Core Controller • Modify Options class to support the new config options • Properly configure SpawningKit • Kill generic process upon shutdown
  • 46. PLAN Integration mode frontend Core Controller Core ApplicationPool • Add user config (e.g. passenger_app_start_command) • Process info from web server
 -OR-
 Perform our own autodetection (Standalone+builtin) • Pass necessary info to ApplicationPool Web server • Autodetect whether auto-supported or generic app • Pass necessary info to Core Controller • Modify Options class to support the new config options • Properly configure SpawningKit • Kill generic process upon shutdown
  • 47. PLAN Integration mode frontend Core Controller Core ApplicationPool • Add user config (e.g. passenger_app_start_command) • Process info from web server
 -OR-
 Perform our own autodetection (Standalone+builtin) • Pass necessary info to ApplicationPool Web server • Autodetect whether auto-supported or generic app • Pass necessary info to Core Controller • Modify Options class to support the new config options • Properly configure SpawningKit • Kill generic process upon shutdown
  • 48. CONFIG TO ACTIVATE EACH SPAWNINGKIT FLOW Generic Auto-supported genericApp = true startsUsingWrapper irrelevant appType irrelevant startupFile irrelevant appStartCommand = [user-provided] genericApp = false, startsUsingWrapper = true, appType = (ruby,python,nodejs), startupFile = (autodetected/user-provided), appStartCommand = (path to interpreter) (path to wrapper)
  • 50. Join the discussion on Github! Thanks for watching! https://github.com/phusion/passenger/issues/2135