Git Product home page Git Product logo

Comments (4)

CamJN avatar CamJN commented on June 24, 2024

Can you please check the user nginx runs as, and that said user has permission to execute the script. Also, you mention having set the hook per-app can you clarify that point a bit? For example Passenger does not support putting the passenger_ctl directive in a server{} block, which is commonly how per-app settings are set, but will cause an nginx config error for this directive, which we can see does not happen in the systemctl status -l nginx output, so I am not sure how that was configured.

from passenger.

looneym avatar looneym commented on June 24, 2024

Thanks for the quick response!

Can you please check the user nginx runs as, and that said user has permission to execute the script

Nginx is running as root with the worker processes running as nobody:

[ec2-user@intercom-production-system-test-web ~]$ ps aux | grep nginx
root     1106236  0.0  0.0  82344  3248 ?        Ss   Nov30   0:00 nginx: master process /opt/nginx/sbin/nginx
nobody   1106237  0.0  0.0  86596 12284 ?        S    Nov30   0:01 nginx: worker process
nobody   1106238  0.0  0.0  86596 12336 ?        S    Nov30   0:01 nginx: worker process
nobody   1106239  0.0  0.0  86596  8256 ?        S    Nov30   0:01 nginx: worker process
nobody   1106240  0.0  0.0  86596 12272 ?        S    Nov30   0:01 nginx: worker process
[ec2-user@intercom-production-system-test-web ~]$ sudo -u nobody /usr/local/bin/passenger_hook_test.sh
/usr/local/bin/passenger_hook_test.sh: line 5: /tmp/hook_test.log: Permission denied

The passenger process runs as ec2-user which also has permissions to execute the script

[ec2-user@intercom-production-system-test-web ~]$ ps aux | grep passenger
root      840976  0.0  0.1 256484 30796 ?        S    Nov30   1:19 passenger-datadog
ec2-user 1106178  0.0  0.0 293796 15968 ?        Ssl  Nov30   0:00 /usr/bin/ruby /usr/local/bin/flying-passenger --socket-file=/apps/intercom/current/log/flying-passenger.sock --max-pool-size=32 --daemonize --log-file=/apps/intercom/current/log/passenger-debug.log --pid-file=/apps/intercom/current/log/flying-passenger.pid
ec2-user 1215720  0.0  0.0 119424  1004 pts/0    S+   10:52   0:00 grep --color=auto passenger
[ec2-user@intercom-production-system-test-web ~]$ sudo -u ec2-user /usr/local/bin/passenger_hook_test.sh

You mention having set the hook per-app can you clarify that point a bit?

Yep sorry this was indeed a bit unclear on my part. We have a global nginx.conf file and compose the configuration with additional files generated as part of our application deployment process.

Here's the abridged version of the global nginx.conf

http {
  passenger_ctl hook_spawn_failed /usr/local/bin/passenger_spawn_failed.sh;
  passenger_ctl hook_before_watchdog_initialization /usr/local/bin/passenger_hook_test.sh;
  passenger_ctl hook_attached_process /usr/local/bin/passenger_hook_test.sh;
}

include "/opt/nginx/conf/conf.d/generated-39c9c5f82db8.conf";

Inside of generated-39c9c5f82db8.conf the hook configuration is top-level and not inside any config block:

passenger_ctl hook_spawn_failed /usr/local/bin/passenger_spawn_failed.sh;
passenger_ctl hook_before_watchdog_initialization /usr/local/bin/passenger_hook_test.sh;
passenger_ctl hook_attached_process /usr/local/bin/passenger_hook_test.sh;

I wasn't sure whether to add these at the global level or in the composed files so added them in both during the debugging process, but it didn't work when only adding them to a single file.

from passenger.

CamJN avatar CamJN commented on June 24, 2024

Can you try adding --ctl "hook_spawn_failed=/usr/local/bin/passenger_spawn_failed.sh" to your flying passenger start command? Most nginx directives that are only valid in the global context, e.g. passenger_log_level, have no effect when using Flying Passenger. Instead, you are supposed to pass these configuration directives through command line options to the Flying Passenger daemon. Configuration directives that have no effect on Flying Passenger are documented as such. You can assume that configuration directives that are not documented as such, work fine on Flying Passenger. You can also use flying-passenger --help to see the options that it takes.

from passenger.

looneym avatar looneym commented on June 24, 2024

This is now working when using the --ctl option. Thanks for your help.

from passenger.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.