Slotting and PHP-FPM
As I recently wrote about, Gentoo is moving to minor version slotting
FPM is currently the only major outstanding issue that I know of. The FPM SAPI ships with an init.d script that starts/stops the process manager. Currently, this init.d script only a single php-fpm binary, the one located in /usr/bin/php-fpm. Unfortunately, the current slotted ebuilds doesn’t even symlink the php-binary to /usr/bin.
Now, there are several ways that slotting could be supported. I will now go through the ones I can think of here. Feedback are most welcomed.
1. Not support slotting
The easiest thing for us would be to simply not support running multiple versions of php-fpm running concurrently by using eselect and having a single init script fire up whatever version is being symlinked to /usr/bin/php-fpm. I don’t really consider this an option.
2. Multiple versions of the init script
Instead of having a single init-script, have one per slot: /etc/init.d/php-fpm<slot> manages /usr/<libdir>/php<slot>/bin/php-fpm
3. Default version and symlinking
Initially one init script that runs a default php slot that users can choose using eselect. Running multiple concurrent versions of php-fpm can be achieved by symlinking the default init script to php-fpm.<slot>, which will manage a php-fpm instance located in that slot regardless of what is selected as default php-fpm version.
4. One init script per slot
Each PHP slot installs one init script that launches the respective php-fpm version.
This would leave users with a bunch of php-fpm init scripts.
5. One init script, configure multiple slots
The mysql init script has a rather advanced way of configuring concurrency. Basically there is only one single init script that pulls up and down all instances of php-fpm at the same time. The instances is defined in /etc/conf.d/mysql.
For FPM, it would work like this:
FPM_slot_1= ( "slot=php5.2" "config=/path/to/some/config" ... "other=options" ) FPM_slot_2= ( "slot=php5.3" "config=/path/to/some/other/config" ... "other=options" )
6. Multiple init scripts, multiple configs
This one is fairly close to the solution used by openVPN. The script /etc/init.d/php-fpm.<foo> maps to one config file /etc/conf.d/php-fpm.<foo>. In the config file, users define which slot to use and which php-fpm.ini file to use.
This one also allows for defining site specific init scripts by having multiple init scripts using the same slot.