phusion / passenger

A fast and robust web server and application server for Ruby, Python and Node.js
https://www.phusionpassenger.com/
MIT License
5.01k stars 547 forks source link

passenger-install-nginx-module is running after installation as a dynamic module #2517

Closed acortes-kz closed 3 months ago

acortes-kz commented 10 months ago

Question 1: What is the problem?

I installed Passenger as a dynamic module as indicated in the documentation. The installation was successful, but then I started to notice that my server was running slowly. Upon checking with the htop command, I found this:

image

This process is consuming CPU and slowing down my server. Is this normal? Should I allocate more resources to my server?

I tried stopping my Nginx service with sudo service nginx stop, but this process continues running.

Question 2: Passenger version and integration mode:

Phusion Passenger(R) 6.0.19 Nginx/1.24.0

Question 3: OS or Linux distro, platform (including version):

Ubuntu 20.04.6 LTS

Question 4: Passenger installation method:

Dynamic Nginx Module

Question 5: Your app's programming language (including any version managers) and framework (including versions):

Ruby 1.9.3 Rails 3.2.12 RVM1.29.12

CamJN commented 10 months ago

It is a common mistake to run passenger start as well as starting Nginx, did you do that?

acortes-kz commented 10 months ago

@CamJN No, I didn't run passenger start. I was starting Nginx with sudo service nginx start, and that was triggering Passenger. How could I stop that service? Is it necessary for that service to be running?

CamJN commented 10 months ago

The passenger-install-nginx-module script isn't a service, and is not necessary to be running once Passenger is setup. The question is how it is being started, as it shouldn't be if I understand your setup correctly.

How are you installing the passenger dynamic module?

acortes-kz commented 10 months ago

I installed Passenger as a dynamic module following this documentation. In summary, it involves downloading the Nginx code and recompiling it with the Passenger module. During this process, there were no issues. I added load_module modules/ngx_http_passenger_module.so; to my nginx.conf file. If my Nginx service is stopped, passenger-status doesn't show any information. However, when I start my Nginx service with sudo service nginx start and run passenger-status again, I can see information about my website. I believe that when I start Nginx, Passenger is initiated automatically. Is that correct?

But I see passenger-install-nginx-module running when I execute htop and that slows down my server.

CamJN commented 10 months ago

You are correct that when you start Nginx, Passenger is initiated automatically. However it shouldn't be running the passenger-install-nginx-module script. In fact passenger does not run that script automatically in any (non-CI) situation I can think of. You can grep the codebase to confirm that. Perhaps you are using something like Capistrano which might run that script for you? Or it's in a Rakefile somewhere? Depending on the size of your server's disk contents I'd suggest grepping your app's files for mention of the script or the whole server if that could be achieved in a reasonable amount of time.

acortes-kz commented 10 months ago

I use Capistrano to perform deployments in my project, but no Capistrano processes or tasks were executed; only the installation of Passenger as a dynamic module was carried out. I assume that at some point, the compilation process did not close properly and remained hanging. Should I kill the process?

However, in Capistrano, I have these tasks to start Passenger. I believe they wouldn't be necessary to run them in each deployment, right?

namespace :passenger do
  task :stop, :only => { :passenger => true }, :on_no_matching_servers => :continue do ; end
  task :start, :only => { :passenger => true }, :on_no_matching_servers => :continue do ; end
  task :restart, :roles => :app, :only => { :passenger => true }, :on_no_matching_servers => :continue do
    run "touch #{File.join(current_path,'tmp','restart.txt')}"
  end
end
CamJN commented 10 months ago

Only the restart is necessary in each deployment. When you built the passenger dynamic nginx module, the passenger-install-nginx-module script shouldn't have been run, as it builds a statically linked nginx with passenger built in, plus the compilation is mostly handled by nginx's configure script and makefile. Perhaps check what the parent process is of the passenger-install-nginx-module script, or a few generations of parent processes? From what you've mentioned doing the script shouldn't have run at all, so it's really quite strange.

acortes-kz commented 10 months ago

Indeed, this is quite strange. I have no idea what it could be; however, upon restarting my server, the process disappeared, and CPU consumption decreased.