Skip to content

Mount filesystems again when rotating PHP runtime instance - #519

Merged
jeroenpf merged 3 commits into
trunkfrom
fix/mount-again-when-rotating-php
Sep 10, 2024
Merged

Mount filesystems again when rotating PHP runtime instance#519
jeroenpf merged 3 commits into
trunkfrom
fix/mount-again-when-rotating-php

Conversation

@jeroenpf

@jeroenpf jeroenpf commented Sep 9, 2024

Copy link
Copy Markdown
Contributor

Fixes #516

Proposed Changes

When rotating an instance, the callback used by the rotation logic should prepare the filesystem and mount the required directories again as they are not retained. Only MEMFS mounts are carried over to the fresh instance but we are using NODEFS for most mounts.

To achieve this, i extracted some logic out of the huge main function startWPNow to make it reusable when creating the first instance AND during the rotation.

Not all logic needs to be executed again. We only care about the mounts and PHP settings.

Testing Instructions

  • Create a site
  • Run ab -n 500 http://localhost:<port>/
  • Wait for the 500 requests to run and ensure there are no failing requests
  • Keep an eye on the console where you ran npm start when request 400 has been reached, you should see a log output telling you the PHP instance is being rotated.
  • Observe that you can navigate the WordPress site and WP-admin without issues

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?
@jeroenpf
jeroenpf requested a review from a team September 9, 2024 14:18
@jeroenpf jeroenpf self-assigned this Sep 9, 2024
@jeroenpf
jeroenpf marked this pull request as ready for review September 9, 2024 14:19

@kozer kozer left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested it and works as expected:

❯ ab -n 500 http://localhost:8885/


Benchmarking localhost (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests

Completed 500 requests
Finished 500 requests

image

@fluiddot fluiddot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🎊 ! Great work @jeroenpf 🏅 ! I've confirmed that after 400 requests, the PHP instance was rotated and kept working.

I added a couple of comments but none shouldn't block the PR.

Comment thread vendor/wp-now/src/wp-now.ts Outdated
Comment thread vendor/wp-now/src/wp-now.ts
@jeroenpf
jeroenpf merged commit 5db8d94 into trunk Sep 10, 2024
@jeroenpf
jeroenpf deleted the fix/mount-again-when-rotating-php branch September 10, 2024 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants