passenger_pre_start not working on nginx

1,188 views
Skip to first unread message

Joshua Slayton

unread,
Jan 28, 2011, 3:32:04 PM1/28/11
to Phusion Passenger Discussions
I can't seem to get passenger and nginx to respect the
passenger_pre_start directive. I always have to hit the app myself to
get the application pool going. Here's my nginx.conf (with the
sensitive parts renamed):

user www-data;
worker_processes 8;

error_log /var/log/nginx/error.log;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

access_log /var/log/nginx/access.log;

sendfile on;
keepalive_timeout 65;

gzip on;

passenger_root /usr/local/rvm/gems/ruby-1.9.2-
p0@appname/gems/passenger-3.0.2;
passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-
p0@appname/ruby;
passenger_pre_start http://app0.appname.co/;
passenger_max_pool_size 60;
passenger_log_level 1;

server {
listen 80;
server_name app0.appname.com;
root /home/deploy/appname/public;

passenger_enabled on;
passenger_min_instances 4;
rails_env staging;
rails_framework_spawner_idle_time 0;
rails_app_spawner_idle_time 0;
}
}

Is there something wrong with my configuration? If not, how can I
debug this?

Joshua Slayton

unread,
Jan 28, 2011, 3:56:29 PM1/28/11
to Phusion Passenger Discussions
I should mention I'm using nginx-0.8.54 with Passenger 3.0.2.

Also, I see these lines in the nginx error log every time the server
is started:
[ pid=28432 thr=140218256086816 file=ext/nginx/HelperAgent.cpp:974
time=2011-01-28 12:55:03.562 ]: Passenger helper agent started on PID
28432
[ pid=28429 thr=140094637192992 file=ext/common/Watchdog.cpp:990
time=2011-01-28 12:55:03.580 ]: Web server did not exit gracefully,
forcing shutdown of all service processes...
[ pid=28689 thr=140720873920288 file=ext/nginx/HelperAgent.cpp:974
time=2011-01-28 12:55:03.584 ]: Passenger helper agent started on PID
28689
/usr/bin/env: ruby: No such file or directory

Hongli Lai

unread,
Jan 28, 2011, 4:01:00 PM1/28/11
to phusion-...@googlegroups.com
On Fri, Jan 28, 2011 at 9:32 PM, Joshua Slayton <josh...@gmail.com> wrote:
>    passenger_pre_start       http://app0.appname.co/;
> ...
>        server_name  app0.appname.com;

Typo. You missed an 'm'.

--
Phusion | Ruby & Rails deployment, scaling and tuning solutions

Web: http://www.phusion.nl/
E-mail: in...@phusion.nl
Chamber of commerce no: 08173483 (The Netherlands)

Hongli Lai

unread,
Jan 28, 2011, 4:01:56 PM1/28/11
to phusion-...@googlegroups.com
On Fri, Jan 28, 2011 at 9:56 PM, Joshua Slayton <josh...@gmail.com> wrote:
> /usr/bin/env: ruby: No such file or directory

passenger_pre_start depends on the existance of a 'ruby' command in
Nginx's $PATH. You need to ensure that that is the case.

Joshua Slayton

unread,
Jan 28, 2011, 4:25:06 PM1/28/11
to Phusion Passenger Discussions
Excellent, fixing the $PATH worked. Thank you.

On Jan 28, 1:01 pm, Hongli Lai <hon...@phusion.nl> wrote:
> On Fri, Jan 28, 2011 at 9:56 PM, Joshua Slayton <joshua...@gmail.com> wrote:
> > /usr/bin/env: ruby: No such file or directory
>
> passenger_pre_start depends on the existance of a 'ruby' command in
> Nginx's $PATH. You need to ensure that that is the case.
>
> --
> Phusion | Ruby & Rails deployment, scaling and tuning solutions
>
> Web:http://www.phusion.nl/
> E-mail: i...@phusion.nl

Tinco Andringa

unread,
Nov 15, 2012, 5:30:28 PM11/15/12
to phusion-...@googlegroups.com
The rvm guys have an entire page dedicated to integration with RVM,
they probably know best :)

https://rvm.io/integration/passenger/

Kind regards,
Tinco

On Thu, Nov 15, 2012 at 11:18 PM, Benjamin Grössing
<mailt...@gmail.com> wrote:
> Sorry for digging out that old topic; I just stumbled across the same
> problem (the error.log even says "/usr/bin/env: ruby: No such file or
> directory"). Now I could probably just fix it by setting the $PATH to the
> (current) RVM ruby path as Joshua did, but that feels a bit odd. Just
> curious, why is that even required in that special case of
> passenger_pre_start?
>
> Is there a recommended way for integration with RVM?
>
> Regards
> Benjamin
> --
> You received this message because you are subscribed to the Google Groups
> "Phusion Passenger Discussions" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/phusion-passenger/-/Ytk2Z4FbRIsJ.
> To post to this group, send email to phusion-...@googlegroups.com.
> To unsubscribe from this group, send email to
> phusion-passen...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/phusion-passenger?hl=en.

Benjamin Grössing

unread,
Nov 15, 2012, 5:39:38 PM11/15/12
to phusion-...@googlegroups.com
Thanks for your quick response!

I have done exactly what the RVM page suggests and everything works - but passenger_pre_start. As soon as I define at least one passenger_pre_start directive the error.log shows that it searches for ruby in the path but can't find it (however, the rails app starts up normally on the first page load).

Why is passenger searching for a ruby executable in $PATH as soon as passenger_pre_start is used (instead of just using the binary provided in the passenger_ruby directive)?

Regards
Benjamin


2012/11/15 Tinco Andringa <ti...@phusion.nl>

Tinco Andringa

unread,
Nov 15, 2012, 5:48:52 PM11/15/12
to phusion-...@googlegroups.com
That is strange indeed, I am not sure and would have to investigate
further, have you found a workaround you can use until I figure it
out?

On Thu, Nov 15, 2012 at 11:39 PM, Benjamin Grössing

Benjamin Grössing

unread,
Nov 15, 2012, 6:00:36 PM11/15/12
to phusion-passenger
My workaround is to open up my rails apps manually once after every server restart :-) However, passenger_pre_start is a pretty neat feature (especially when hosting many apps), so it would be great to use that of course. Another workaround I have just tried is to add the RVM binary path (/home/<user>/.rvm/rubies/ruby-1.9.3-p194/bin) to $PATH. After doing so, restarting nginx actually spawns all passenger apps I have specified via passenger_pre_start - just as it should. Still, it would be interesting why $PATH is required here.

Let me know if I can provide you with any further information!

Regards
Benjamin


2012/11/15 Tinco Andringa <ma...@tinco.nl>

Benjamin Grössing

unread,
Nov 21, 2012, 3:56:05 PM11/21/12
to phusion-passenger
Hi Tinco!

Have you already had the time to look into that? I think that's a quite strange behaviour (I actually wonder no one else seems to have troubles with that).

I've had a look into the sources as well and noticed that the files in "helper-scripts" all begin with "#!/usr/bin/env ruby". Are these files used for the passenger_pre_start directive?

Regards
Benjamin


2012/11/16 Benjamin Grössing <mailt...@gmail.com>

Hongli Lai

unread,
Dec 20, 2012, 12:17:30 PM12/20/12
to phusion-...@googlegroups.com

Hi benjamin. The passengerprestart helper script is not invoked through passenger_ruby in the currently implementation. It is just exec'ed directly, which is why it requires a ruby command in PATH. We may want to address this in the future, but for now, please make sure there is a ruby in PATH.

Sent from my Android phone.

Op 21 nov. 2012 21:57 schreef "Benjamin Grössing" <mailt...@gmail.com> het volgende:
Reply all
Reply to author
Forward
0 new messages