Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 471018 - app-eselect/eselect-php / dev-lang/php - incorrect dependency in init script for php-fpm
Summary: app-eselect/eselect-php / dev-lang/php - incorrect dependency in init script ...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Server (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-05-22 16:37 UTC by Shaun Bouckaert
Modified: 2015-11-19 23:35 UTC (History)
5 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Shaun Bouckaert 2013-05-22 16:37:14 UTC
The init script /etc/init.d/php-fpm has the following depend section:

depend() {
        need net
        use apache2 lighttpd nginx
}

As php-fpm doesn't USE the webservers, but is itself used by the web servers, it should not list them as use dependencies. This causes php-fpm to start those servers upon starting, which isn't always desired, and is an incorrect use of this feature.

According to the handbook:

http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4

The use settings informs the init system that this script uses functionality offered by the selected script, but does not directly depend on it. A good example would be use logger or use dns. If those services are available, they will be put in good use, but if you do not have a logger or DNS server the services will still work. If the services exist, then they are started before the script that use's them.

It would be more correct for the webservers to list php-fpm as a use dependency.
Comment 1 Ole Markus With (RETIRED) gentoo-dev 2013-05-27 15:41:39 UTC
I disagree. If I have a webserver installed, I want it running when using php-fpm.
Comment 2 Shaun Bouckaert 2013-06-01 15:45:10 UTC
(In reply to Ole Markus With from comment #1)
> I disagree. If I have a webserver installed, I want it running when using
> php-fpm.

But the webserver uses php-fpm, not the other way around. The webserver should have php-fpm as a use dependency

Unless there's some use you can explain where php-fpm uses the webserver? this is especially a bug because some people use different webservers for different things and not all of them should be running all the time. Starting php-fpm shouldn't trigger them to start.
Comment 3 Ben Kohler gentoo-dev 2013-06-01 15:59:14 UTC
To get to the point, is there some advantage to having apache2/nginx/lighttpd start before php-fpm?  Or is it just a case of "these things are usually used together"?
Comment 4 Ole Markus With (RETIRED) gentoo-dev 2013-06-02 10:59:30 UTC
Yep, it is a convenience thing.

It has been like this for a few years now without any complaints, and if you do not like it, then you should be able to override the deps in your rc.conf
Comment 5 Gordon Pettey 2013-11-02 19:26:32 UTC
Convenience is great, but this isn't convenience; it's plain wrong, according to all standards. For "convenience", that line should also include everything else from virtual/httpd-fastcgi (bozohttpd, cherokee, resin, and skunkweb).
Comment 6 Shaun Bouckaert 2013-11-03 14:59:14 UTC
this is another example of developers/maintainers doing what's convenient for them instead of doing things properly.
Comment 7 kfm 2014-06-17 15:58:30 UTC
Shaun is 100% correct and the irritation expressed in his most recent comment is wholly justified. Starting any webserver configured to interact with php-fpm *prior* to php-fpm provides a window of opportunity for requests to be fielded by the webserver that will *fail* because php-fpm is not yet able to service any requests, leading to "502 Bad Gateway" errors and such.

This window of opportunity is increased further for those that run busy sites requiring many concurrent instances of php in a pool because the overhead of starting and stopping php-fpm can can be significant.

Ole Markus, your failure to understand this is most disparaging. All that is required to rectify this is to switch the potential startup order where both webserver and php-fpm reside in the default runlevel. In other words:

  1) Remove the use depends from /etc/init.d/php-fpm (entirely)
  2) Have the relevant devs add "use php-fpm" to the runscripts for apache/nginx/lighttpd etc

Thus, if the user adds both php-fpm and their webserver of choice to the default runlevel, then php-fpm is guaranteed to start first. Therefore, PHP will function from the instant that the webserver is able to handle requests. It really is as simple as that.

Worse still, for those that do it *properly* and specify rc_use="php-fpm" in /etc/conf.d/<webserver-of-choice>, the result is a dependency loop, requiring users to take matters into their own hands and locally enact the fix that we are asking for directly (see 1st point above).
Comment 8 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2014-12-11 13:59:48 UTC
I have to agree with the others here. Logically saying, FPM is used by the webserver, and you want it started first for the webserver to be able to serve content properly.

@openrc, could I ask for your opinion on this? You know best how the deps in initscripts are supposed to be set.
Comment 9 SpanKY gentoo-dev 2015-06-01 11:20:33 UTC
(In reply to Michał Górny from comment #8)

iiuc, php-fpm itself (1) does not use a web server and (2) must be started before whatever web server the user is using.  if that's the case, then Kerin is correct -- php-fpm's depend is wrong (the whole thing should be deleted including the net statement) and users that want php-fpm should list it in their webserver's conf.d file using existing rc_xxx dep vars.
Comment 10 Ole Markus With (RETIRED) gentoo-dev 2015-06-01 11:33:00 UTC
Hmm ... Okay. That makes sense. I'll revisit those dependencies.
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2015-11-01 19:12:55 UTC
We've got PR for this too: https://github.com/gentoo/gentoo/pull/316
Comment 12 Michael Orlitzky gentoo-dev 2015-11-19 23:35:31 UTC
This should be fixed in the latest revision of eselect-php:

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=79b8064e2ee191fc3d63e716e6ab4245332fe5c9

Please give it a try and let me know if there are any more problems.