[CB] Support for building first, not yet 'make install'

Jan_E

Verified User
Joined
Apr 29, 2011
Messages
128
Location
Amsterdam, NL, EU
I am in the process of changing the php_mode of all my 4 PHP releases from mod_php (1) and fastcgi (3) to php-fpm. Because I want the downtime to be as short as possible, I was looking for a possibility to do it in 2 steps: first step is building the 4 PHP versions and second step is to install them.

The idea is like this:
Code:
./build set php4_mode php-fpm
./build set php3_mode php-fpm
./build set php2_mode php-fpm
./build set php1_mode php-fpm
./build set mod_ruid2 yes
./build set clean no
./build php_expert 7.2 php-fpm make
./build php_expert 5.3 php-fpm make
./build php_expert 7.1 php-fpm make
./build php_expert 5.6 php-fpm make
./build php_expert 7.2 php-fpm install
./build php_expert 5.3 php-fpm install
./build php_expert 7.1 php-fpm install
./build php_expert 5.6 php-fpm install
./build set clean yes
./build rewrite_confs

With a small patch of the build script this is possible:
Code:
diff --git a/build b/build_make
index 229b9dc..b5c71c9 100755
--- a/build
+++ b/build_make
@@ -4342,7 +4342,7 @@ if [ "${BUILD_SECTIONS_CASE}" = "1" ]; then
 	BUILD_EXPERIENCED_SET="php_expert php_htscanner2 todovecot set_service"
 	BUILD_EXPERIENCED_DESC="Recommended for experienced users only (!)"
 	BUILD_EXPERIENCED_REQADD="php_expert php_htscanner2 set_service"
-	PHP_EXPERT_ADDIT="php_release php_mode"
+	PHP_EXPERT_ADDIT="php_release php_mode [make]"
 	PHP_HTSCANNER2_ADDIT="php_release"
 	SET_SERVICE_ADDIT="service ON|OFF|delete"
 fi
@@ -4884,8 +4884,8 @@ initJSONVars() {
 	COMP_UPDATE_DATA_NAME="Download packages"
 	COMP_UPDATE_DATA_DESC="Downloads packages needed for the CustomBuild script (does not include versions.txt file or the 'build' file)."
 
-	COMP_PHP_EXPERT_NAME="Install specified PHP version"
-	COMP_PHP_EXPERT_DESC="Installs specified PHP version, but does not apply any automatic configuration to it."
+	COMP_PHP_EXPERT_NAME="Make or install specified PHP version"
+	COMP_PHP_EXPERT_DESC="Builds specified PHP version, but does not apply any automatic configuration to it."
 
 	COMP_PHP_HTSCANNER2_NAME="Build php_htscanner2"
 	COMP_PHP_HTSCANNER2_DESC="Install/update php_htscanner2 component used by Apache and PHP."
@@ -11524,6 +11524,7 @@ doPCRE() {
 doPhp_build() {
 	#$1 is PHP release
 	#$2 is PHP mode
+	#$3 if 'make': do not install (yet)
 	INT_RELEASE=$1
 	INT_MODE=$2
 	SHORT_RELEASE=`echo ${INT_RELEASE} | tr -d '.'`
@@ -12046,6 +12047,10 @@ doPhp_build() {
 	done
 	echo "Make Complete"
 
+	if [ "$3" = "make" ]; then
+		do_exit 0 "Build not installed. Run './build php_expert $1 $2' to install."
+	fi
+
 	#change the pear settings to remove the -n option.
 	#the default memory limit was messing this up.
 	/usr/bin/perl -pi -e 's/PEAR_INSTALL_FLAGS = .*/PEAR_INSTALL_FLAGS = -dshort_open_tag=0 -dsafe_mode=0/' Makefile
@@ -26849,7 +26854,7 @@ case "$1" in
 		;;
 	php) doChecks; doPhp
 		;;
-	php_expert) doChecks; doPhp_build $2 $3
+	php_expert) doChecks; doPhp_build $2 $3 $4
 		;;
 	php_ini) doChecks; doPhpIni
 		;;
Can this be implemented?
 
I improved the patch a little bit, to make building of PHP a 3 step process:

  1. ./build php_expert php_release php_mode make: make only, do not copy to final location
  2. ./build php_expert php_release php_mode install: make install only to final location, but do not perform rewrite_confs or restart the webserver. This step is much shorter then step 1, because the compilation already has been done.
  3. ./build apache and/or ./build rewrite_confs: restart the webserver with the new php_releases.
Using this setup I was able to move from mod_php + 3 * fastcgi to 4 * php-fpm with virtually no downtime. The new patch:
Code:
diff --git a/build b/build_make
index ee55eec..34da28c 100755
--- a/build
+++ b/build_make
@@ -4350,7 +4350,7 @@ if [ "${BUILD_SECTIONS_CASE}" = "1" ]; then
 	BUILD_EXPERIENCED_SET="php_expert php_htscanner2 todovecot set_service"
 	BUILD_EXPERIENCED_DESC="Recommended for experienced users only (!)"
 	BUILD_EXPERIENCED_REQADD="php_expert php_htscanner2 set_service"
-	PHP_EXPERT_ADDIT="php_release php_mode"
+	PHP_EXPERT_ADDIT="php_release php_mode [make]"
 	PHP_HTSCANNER2_ADDIT="php_release"
 	SET_SERVICE_ADDIT="service ON|OFF|delete"
 fi
@@ -4892,8 +4892,8 @@ initJSONVars() {
 	COMP_UPDATE_DATA_NAME="Download packages"
 	COMP_UPDATE_DATA_DESC="Downloads packages needed for the CustomBuild script (does not include versions.txt file or the 'build' file)."
 
-	COMP_PHP_EXPERT_NAME="Install specified PHP version"
-	COMP_PHP_EXPERT_DESC="Installs specified PHP version, but does not apply any automatic configuration to it."
+	COMP_PHP_EXPERT_NAME="Make or install specified PHP version"
+	COMP_PHP_EXPERT_DESC="Builds specified PHP version, but does not apply any automatic configuration to it."
 
 	COMP_PHP_HTSCANNER2_NAME="Build php_htscanner2"
 	COMP_PHP_HTSCANNER2_DESC="Install/update php_htscanner2 component used by Apache and PHP."
@@ -11532,6 +11532,8 @@ doPCRE() {
 doPhp_build() {
 	#$1 is PHP release
 	#$2 is PHP mode
+	#$3 if 'make': do not install (yet)
+	#$3 if 'install': install, but do not rewrite_confs yet
 	INT_RELEASE=$1
 	INT_MODE=$2
 	SHORT_RELEASE=`echo ${INT_RELEASE} | tr -d '.'`
@@ -12054,6 +12056,10 @@ doPhp_build() {
 	done
 	echo "Make Complete"
 
+	if [ "$3" = "make" ]; then
+		do_exit 0 "Build not installed. Run './build php_expert $1 $2' to install."
+	fi
+
 	#change the pear settings to remove the -n option.
 	#the default memory limit was messing this up.
 	/usr/bin/perl -pi -e 's/PEAR_INSTALL_FLAGS = .*/PEAR_INSTALL_FLAGS = -dshort_open_tag=0 -dsafe_mode=0/' Makefile
@@ -12445,6 +12451,10 @@ doPhp_build() {
 
 	removeLockfile
 
+	if [ "$3" = "install" ]; then
+		do_exit 0 "Build installed. Run './build rewrite_confs' to activate."
+	fi
+
 	if [ "${WEBSERVER_OPT}" = "apache" ] || [ "${WEBSERVER_OPT}" = "nginx_apache" ]; then
 		echo "Restarting apache."
 		control_service httpd restart
@@ -26857,7 +26867,7 @@ case "$1" in
 		;;
 	php) doChecks; doPhp
 		;;
-	php_expert) doChecks; doPhp_build $2 $3
+	php_expert) doChecks; doPhp_build $2 $3 $4
 		;;
 	php_ini) doChecks; doPhpIni
 		;;
Please apply
 
Last edited:
After a few dry-runs on our staging server, I changed the 4 PHP releases in production. Timings:

Code:
Wed Oct 16 15:57 - start php-fpm 7.2 make
Wed Oct 16 16:05 - start php-fpm 5.3 make
Wed Oct 16 16:09 - start php-fpm 7.1 make
Wed Oct 16 16:17 - start php-fpm 5.6 make

Wed Oct 16 16:24 - start php-fpm 7.2 install
Wed Oct 16 16:26 - start php-fpm 5.3 install
Wed Oct 16 16:28 - start php-fpm 7.1 install
Wed Oct 16 16:31 - start php-fpm 5.6 install

Wed Oct 16 16:34 - ./build apache
Wed Oct 16 16:36 - rewrite_confs: restart apache with 4 php-fpm releases and event mpm
Explanation: without the patch I would have a downtime from (at least) 16:09 - 16:26, from the end of the first PHP recompile up until the finish of the last one, plus some minutes for the build of Apache. About 20 minutes was far too long to be down.

With the first patch I would have had a downtime from 16:26 - 16:36, from the Apache restart at the 'make install' of the first PHP up until the final restart. Still 10 minutes downtime.

With the second patch I virtually had no downtime at all. Only the restart of Apache with the 4 PHP releases at 16:36 could have been noticable for visitors of our websites. Mission accomplished.

It would be really nice if this could be applied to Directadmin.
 
Back
Top