determining autodetected app_type?

13 views
Skip to first unread message

David J. Malan

unread,
Jan 21, 2017, 5:06:46 PM1/21/17
to Phusion Passenger Discussions
Hi all,

Is there a way to ascertain which app_type was autodetected by Passenger, so as to include directives in nginx.conf.erb conditionally? It looks like @options[:app_type] only has a value if an app_type was explicitly specified, as with --app-type at the command line?

Many thanks!

David

Daniel Knoppel

unread,
Jan 23, 2017, 5:39:15 AM1/23/17
to Phusion Passenger Discussions
I don't think so, the app type setting is for telling passenger what you want it to detect, not for collecting the result. What are you trying to accomplish? Perhaps you can do something with the hooks: https://www.phusionpassenger.com/library/indepth/hooks.html

- Daniel

David J. Malan

unread,
Jan 25, 2017, 10:06:07 AM1/25/17
to Phusion Passenger Discussions
Hi Daniel,

Thanks very much for the follow-up. For CS50 at Harvard, we're preparing a Docker image that will server as the default image for a number of web apps, some written in Python, some in Node.js, and some in PHP. To keep usage uniform, we've standardized on Passenger (thank you!) to which we've effectively added some PHP support. Essentially, the Dockerfile installs some additional dependencies, we wrap `passenger` with a script that sets some environment variables, and we use hooks to start and stop php5-fpm.

It'd be ideal, though, to start php5-fpm conditionally, only if Passenger has autodetected a Python or Node.js app, and to include some directives in our nginx.conf.erb conditionally as well.

Might there be a clever way to determine within nginx.conf.erb which type of app Passenger has autodetected? (We could then isolate all of this conditional logic to the ERB, including the Nginx directives and Passenger hooks conditionally.)

Many thanks!

David

Daniel Knoppel

unread,
Jan 25, 2017, 10:59:46 AM1/25/17
to Phusion Passenger Discussions
Thanks very much for the follow-up. For CS50 at Harvard, we're preparing a Docker image that will server as the default image for a number of web apps, some written in Python, some in Node.js, and some in PHP. To keep usage uniform, we've standardized on Passenger (thank you!) to which we've effectively added some PHP support. Essentially, the Dockerfile installs some additional dependencies, we wrap `passenger` with a script that sets some environment variables, and we use hooks to start and stop php5-fpm.

It'd be ideal, though, to start php5-fpm conditionally, only if Passenger has autodetected a Python or Node.js app, and to include some directives in our nginx.conf.erb conditionally as well.

Interesting. But I'm not entirely sure I understand this: you want php5-fpm to start if the application type is Python or Node? Or did you mean the opposite? What are the conditions under which php5-fpm should be started?

Basically the Nginx config is something that needs to be fed to Nginx upon start. This is before the Passenger itself starts (happens after nginx is up). By the time any detection happens the config has already been fed, so at a first glance I don't see an easy way to do this.

David J. Malan

unread,
Feb 10, 2017, 12:39:10 PM2/10/17
to Phusion Passenger Discussions
Thanks very much for the follow-up. For CS50 at Harvard, we're preparing a Docker image that will server as the default image for a number of web apps, some written in Python, some in Node.js, and some in PHP. To keep usage uniform, we've standardized on Passenger (thank you!) to which we've effectively added some PHP support. Essentially, the Dockerfile installs some additional dependencies, we wrap `passenger` with a script that sets some environment variables, and we use hooks to start and stop php5-fpm.

It'd be ideal, though, to start php5-fpm conditionally, only if Passenger has autodetected a Python or Node.js app, and to include some directives in our nginx.conf.erb conditionally as well.

Interesting. But I'm not entirely sure I understand this: you want php5-fpm to start if the application type is Python or Node? Or did you mean the opposite? What are the conditions under which php5-fpm should be started?

Ah, apologies, I meant to say "only if Passenger has _not_ autodetected a Python or Node.js app"!

But I think we've been able to achieve our intended result thanks to AppFinder.looks_like_app_directory?, whereby we only include the Nginx directives for PHP (and, in turn, the hooks that start/stop php5-fpm) if autodetection fails:


Thank you kindly!

David 
Reply all
Reply to author
Forward
0 new messages