Skip to content

Commit

Permalink
Merge pull request #1074 from markshust/feature/fix-performance-issue…
Browse files Browse the repository at this point in the history
…-spx
  • Loading branch information
markshust authored Feb 25, 2024
2 parents 45ce137 + 2820aed commit ef9498b
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion compose/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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.')"
Expand Down Expand Up @@ -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.')"
Expand Down
55 changes: 55 additions & 0 deletions compose/bin/spx
Original file line number Diff line number Diff line change
@@ -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
2 changes: 0 additions & 2 deletions images/php/8.1/conf/spx.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
zlib.output_compression = 0

extension = /usr/lib/php-spx/modules/spx.so
spx.http_enabled = 1
spx.http_key = "dev"
Expand Down
2 changes: 0 additions & 2 deletions images/php/8.2/conf/spx.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
zlib.output_compression = 0

extension = /usr/lib/php-spx/modules/spx.so
spx.http_enabled = 1
spx.http_key = "dev"
Expand Down
2 changes: 0 additions & 2 deletions images/php/8.3/conf/spx.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
zlib.output_compression = 0

extension = /usr/lib/php-spx/modules/spx.so
spx.http_enabled = 1
spx.http_key = "dev"
Expand Down

0 comments on commit ef9498b

Please sign in to comment.