Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wp-env: Auto-start cli service to reduce command time #49168

Closed
westonruter opened this issue Mar 17, 2023 · 1 comment · Fixed by #50007
Closed

wp-env: Auto-start cli service to reduce command time #49168

westonruter opened this issue Mar 17, 2023 · 1 comment · Fixed by #50007
Assignees
Labels
[Package] Env /packages/env [Type] Enhancement A suggestion for improvement.

Comments

@westonruter
Copy link
Member

What problem does this address?

Running WP-CLI commands is relatively slow due to Docker and the container not being automatically started. Consider the following:

$ time npx wp-env run cli wp post list
ℹ Starting 'wp post list' on the cli container. 

Starting aabe871bb4b92d5867707c9f76aa7c03_mysql_1 ... done
Starting aabe871bb4b92d5867707c9f76aa7c03_wordpress_1 ... done
+----+--------------+-------------+---------------------+-------------+
| ID | post_title   | post_name   | post_date           | post_status |
+----+--------------+-------------+---------------------+-------------+
| 5  | Script       | script      | 2022-11-21 18:38:24 | publish     |
| 1  | Hello world! | hello-world | 2022-11-21 18:36:23 | publish     |
+----+--------------+-------------+---------------------+-------------+
✔ Ran `wp post list` in 'cli'. (in 2s 105ms)

real    0m2.419s
user    0m0.611s
sys     0m0.147s

It takes 2½ seconds to invoke a command. Compare this with when the container is already up and running:

$ time npx wp-env run cli bash
ℹ Starting 'bash' on the cli container. Exit bash with ctrl-d.

Starting aabe871bb4b92d5867707c9f76aa7c03_mysql_1 ... done
Starting aabe871bb4b92d5867707c9f76aa7c03_wordpress_1 ... done
bash-5.1$ time wp post list
+----+--------------+-------------+---------------------+-------------+
| ID | post_title   | post_name   | post_date           | post_status |
+----+--------------+-------------+---------------------+-------------+
| 5  | Script       | script      | 2022-11-21 18:38:24 | publish     |
| 1  | Hello world! | hello-world | 2022-11-21 18:36:23 | publish     |
+----+--------------+-------------+---------------------+-------------+

real    0m0.254s
user    0m0.203s
sys     0m0.046s

Just a quarter second, almost 10x faster.

What is your proposed solution?

Since the wordpress and mariadb containers for development and tests are all started automatically, couldn't the same be done for CLI? The same goes for the phpunit container.

@westonruter westonruter added [Type] Enhancement A suggestion for improvement. [Package] Env /packages/env labels Mar 17, 2023
@github-actions github-actions bot added the [Status] In Progress Tracking issues with work in progress label Apr 21, 2023
@noahtallen
Copy link
Member

Good idea! I implemented this in #50007

@priethor priethor removed the [Status] In Progress Tracking issues with work in progress label May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Env /packages/env [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants