소스 검색

Merge pull request #1074 from markshust/feature/fix-performance-issue-spx

Mark Shust 1 년 전
부모
커밋
ef9498b99a
7개의 변경된 파일59개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 0
      CHANGELOG.md
  2. 1 0
      README.md
  3. 2 1
      compose/Makefile
  4. 55 0
      compose/bin/spx
  5. 0 2
      images/php/8.1/conf/spx.ini
  6. 0 2
      images/php/8.2/conf/spx.ini
  7. 0 2
      images/php/8.3/conf/spx.ini

+ 1 - 0
CHANGELOG.md

@@ -20,6 +20,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
 - New `bin/setup-pwa-studio-sampledata` command to install Magento PWA Studio sample data, facilitating easier PWA development setups [#1045](https://github.com/markshust/docker-magento/pull/1045).
 - New `bin/deploy` script to deply Magento in pipeline [PR #926](https://github.com/markshust/docker-magento/pull/926).
 - New `bin/magento-version` script which outputs current Magento version [PR #931](https://github.com/markshust/docker-magento/pull/931).
+- New `bin/spx` script to enable or disable SPX [PR #1074](https://github.com/markshust/docker-magento/pull/1074).
 
 ### Updated
 - Node.js to version 20.x LTS [PR #1071](https://github.com/markshust/docker-magento/pull/1071).

+ 1 - 0
README.md

@@ -318,6 +318,7 @@ It is recommended to keep your root docker config files in one repository, and y
 - `bin/setup-pwa-studio-sampledata`: This script makes it easier to install Venia sample data. Pass in your base site domain, otherwise the default `master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud` will be used. Ex: `bin/setup-pwa-studio-sampledata magento.test`.
 - `bin/setup-ssl`: Generate an SSL certificate for one or more domains. Ex. `bin/setup-ssl magento.test foo.test`
 - `bin/setup-ssl-ca`: Generate a certificate authority and copy it to the host.
+- `bin/spx`: Disable or enable output compression to enable or disbale SPX. Accepts params `disable` (default) or `enable`. Ex. `bin/spx enable`
 - `bin/start`: Start all containers, good practice to use this instead of `docker-compose up -d`, as it may contain additional helpers.
 - `bin/status`: Check the container status.
 - `bin/stop`: Stop all project containers.

+ 2 - 1
compose/Makefile

@@ -31,7 +31,7 @@ help:
 	@echo "$(call format,dev-urn-catalog-generate,'Generate URNs for PHPStorm and remap paths to local host.')"
 	@echo "$(call format,devconsole,'Alias for n98-magerun2 dev:console.')"
 	@echo "$(call format,devtools-cli-check,'Check & install the CLI devtools if missing from system.')"
-	@echo "$(call format,docker-stats,'Display status for CPU, memory usage, and memory limit of currently-running Docker containers.')"
+	@echo "$(call format,docker-stats,'Display status for CPU$(comma) memory usage$(comma) and memory limit of currently-running Docker containers.')"
 	@echo "$(call format,download,'Download & extract specific Magento version to the src directory.')"
 	@echo "$(call format,fixowns,'This will fix filesystem ownerships within the container.')"
 	@echo "$(call format,fixperms,'This will fix filesystem permissions within the container.')"
@@ -59,6 +59,7 @@ help:
 	@echo "$(call format,setup-pwa-studio,'(BETA) Install PWA Studio.')"
 	@echo "$(call format,setup-ssl,'Generate an SSL certificate for one or more domains.')"
 	@echo "$(call format,setup-ssl-ca,'Generate a certificate authority and copy it to the host.')"
+	@echo "$(call format,spx,'Disable or enable output compression to enable or disbale SPX.')"
 	@echo "$(call format,start,'Start all containers.')"
 	@echo "$(call format,status,'Check the container status.')"
 	@echo "$(call format,stop,'Stop all containers.')"

+ 55 - 0
compose/bin/spx

@@ -0,0 +1,55 @@
+#!/usr/bin/env bash
+
+S=$(bin/clinotty cat /usr/local/etc/php/php.ini | grep -iGc 'zlib.output_compression = 1');
+
+spx_status() {
+    if [[ $S == 1 ]]; then
+        echo "Output compression is enabled, so you cannot currently debug with SPX."
+    else
+        echo "Output compression is disabled, so you can currently debug with SPX."
+    fi
+}
+
+spx_toggle() {
+    if [[ $S == 1 ]]; then
+        spx_enable
+    else
+        spx_disable
+    fi
+}
+
+spx_enable() {
+    if [[ $S == 1 ]]; then
+        bin/root sed -i -e 's/^zlib.output_compression = 1/zlib.output_compression = 0/g' /usr/local/etc/php/php.ini
+        sleep 1
+        bin/restart phpfpm
+        echo "Output compression is now disabled, so you can start debugging with SPX."
+    else
+        echo "Output compression is already disabled, so you can start debugging with SPX."
+    fi
+}
+
+spx_disable() {
+    if [[ $S == 0 ]]; then
+        bin/root sed -i -e 's/^zlib.output_compression = 0/zlib.output_compression = 1/g' /usr/local/etc/php/php.ini
+        sleep 1
+        bin/restart phpfpm
+        echo "Output compression is now enabled, so you can no longer debug with SPX."
+    else
+        echo "Output compression is already enabled, so you can no longer debug with SPX."
+    fi
+}
+
+firstArgLetter="$(echo "$1" | head -c 1)"
+
+if [[ $firstArgLetter == "d" ]]; then
+    spx_disable
+elif [[ $firstArgLetter == "e" ]]; then
+    spx_enable
+elif [[ $firstArgLetter == "t" ]]; then
+    spx_toggle
+elif [[ $firstArgLetter == "s" ]]; then
+    spx_status
+else
+    printf "Please specify either 'disable', 'enable', 'status' or 'toggle' as an argument.\nEx: bin/spx status\n"
+fi

+ 0 - 2
images/php/8.1/conf/spx.ini

@@ -1,5 +1,3 @@
-zlib.output_compression = 0
-
 extension = /usr/lib/php-spx/modules/spx.so
 spx.http_enabled = 1
 spx.http_key = "dev"

+ 0 - 2
images/php/8.2/conf/spx.ini

@@ -1,5 +1,3 @@
-zlib.output_compression = 0
-
 extension = /usr/lib/php-spx/modules/spx.so
 spx.http_enabled = 1
 spx.http_key = "dev"

+ 0 - 2
images/php/8.3/conf/spx.ini

@@ -1,5 +1,3 @@
-zlib.output_compression = 0
-
 extension = /usr/lib/php-spx/modules/spx.so
 spx.http_enabled = 1
 spx.http_key = "dev"