Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 489270 - dev-lang/php-5.4.17 with fpm flag - after reboot sockets path don't recreate automatically
Summary: dev-lang/php-5.4.17 with fpm flag - after reboot sockets path don't recreate ...
Status: RESOLVED CANTFIX
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: PHP Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-24 15:42 UTC by Krzysztof Tomczyk
Modified: 2015-11-23 00:35 UTC (History)
0 users

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 Krzysztof Tomczyk 2013-10-24 15:42:38 UTC
I think that php-fpm initscript should include ensure for fpm - unix sockets path. It could be something like that below:

start_pre() {
        checkpath --directory --owner "${FPM_USER}":"${FPM_GROUP}" "${FPM_SOCKETS_DIR}"
}

Variables must be defined in /etc/conf.d/php-fpm

Now there is a problem after reboot - fpm doesn't start because of lacking socket directory

Reproducible: Always

Steps to Reproduce:
1.Configure fpm, add to autostart - rc-update add php-fpm
2. Reboot system

Actual Results:  
On next start initscript will fail (lack of /var/run/php5-fpm directory)

Expected Results:  
It should work after reboot
Comment 1 Ole Markus With (RETIRED) gentoo-dev 2013-10-25 15:03:55 UTC
I do not plan on making any such feature at the moment. Have you tried going upstream with this?
Comment 2 Krzysztof Tomczyk 2013-10-26 16:08:01 UTC
Why uptream? In my view it's related to Gentoo baselayout and initscripts which clean run directories on shutdown. I see similar fnuctionality in many Gentoo initscripts (e.g. mysql, mongodb, postgresql) so that's why I proposed such a solution. Now if I try to run php-fpm with Gentoo's default configuration (sockets in /var/run/php5-fpm) I'll get error on startup - in general initscript doesn't work. If it's only a matter of contribution and preparing such a patch to ebuild I'm ready to do it :)
Comment 3 Michael Orlitzky gentoo-dev 2015-11-22 22:41:25 UTC
That directory is specific to our init script.. it's not easy to find the documentation, but the way that OpenRC suggests to do this is by calling `checkpath` before we attempt to use the path. The docs are hidden in `man openrc-run`.

The annoying part would be having to add those variables and a conf file. Since we currently have that directory root:root, I think PHP probably drops permissions after creating the socket. If we're lucky and that's the case, we won't need to mess with the variables at all.

The ${FPM_SOCKETS_DIR} is hard-coded, so that's not a problem =)
Comment 4 Michael Orlitzky gentoo-dev 2015-11-22 23:12:51 UTC
(In reply to Michael Orlitzky from comment #3)
> 
> The annoying part would be having to add those variables and a conf file.
> Since we currently have that directory root:root, I think PHP probably drops
> permissions after creating the socket. If we're lucky and that's the case,
> we won't need to mess with the variables at all.
> 
> The ${FPM_SOCKETS_DIR} is hard-coded, so that's not a problem =)

Oops, I jumped the gun. I was thinking of the PID directory being hard-coded and root:root. We may not be able to fix this in the init script after all. The settings for the user, group, and socket are all found in php-fpm.conf which is PHP's file, not ours. By default, it listens on a TCP socket and runs as nobody/nobody. That will work fine right after you install it.

The problem is only if you change the socket to a unix socket (in php-fpm.conf) and point it to somewhere that doesn't exist, right? In that case, we have no way to get the value of the "listen" variable out of php-fpm.conf, so we have no way to create it beforehand.

If we went the conf.d file route, we would be forced to override the user's php-fpm.conf for the user, group, and "listen" variables which I think would be pretty annoying and raise complaints.

So I really don't see a way to fix it in the init script. Sorry, but I'm changing my opinion to "don't point the socket at a directory that doesn't exist." *If* it was going to get auto-created, php-fpm would have to do it, since only it knows where you've configured the socket to go.
Comment 5 Michael Orlitzky gentoo-dev 2015-11-22 23:33:31 UTC
One more thing (sorry for the spam). I just tried the conf.d override -- I figured maybe we could do nothing if the variables FPM_USER, FPM_GROUP, etc. were unset. Then I could comment them by default. That wouldn't be so annoying.

The bigger problem is that, to set the socket path, we need to override the "listen" variable on the command-line. So that third variable needs to be something like FPM_LISTEN. But then, things get hairy: the "listen" variable takes four different forms:

  * ip.add.re.ss:port
  * [ip:6:addr:ess]:port
  * port
  * /path/to/unix/socket

So now we have to parse that thing to find out if it's a path.. ugh. I guess we could check to see if the first character is a slash?
Comment 6 Michael Orlitzky gentoo-dev 2015-11-23 00:35:31 UTC
Haha, 'twas all in vain.

It turns out that the only settings you can override on the command-line are php.ini settings, NOT php-fpm.conf settings. So even after I create a conf.d file with FPM_USER, FPM_GROUP, and FPM_LISTEN, there's no way to pass them to the daemon!

You could try sending this upstream, since it does make sense to stick the socket in a temporary location like /run or /var/run. I see a lot of similar complaints on e.g. stackoverflow. The only other option I see is to put the socket in a permanent location that you can create once with the correct permissions. Or the ugly way: editing your init script.

I tried.

We could also revisit this if they give us the ability to override php-fpm.conf settings on the command-line.