-
-
Notifications
You must be signed in to change notification settings - Fork 22
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
Demo a local daemonized cache with turborepo #475
base: main
Are you sure you want to change the base?
Conversation
🚀 Deployed on https://62864a4918eb9c04da106e91--limber.netlify.app |
3c0f4c9
to
ff9e113
Compare
@@ -0,0 +1,5 @@ | |||
{ | |||
"teamId": "team_my-fake-but-local-team", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per the docs, the teamId
must begin with team_
@@ -21,6 +25,7 @@ | |||
}, | |||
"devDependencies": { | |||
"concurrently": "^7.0.0", | |||
"pm2": "^5.2.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"daemon": "pm2 start ./launch-daemon.sh", | ||
"daemon:status": "pm2 ls", | ||
"daemon:stop": "pm2 stop ./launch-daemon.sh", | ||
"reset": "git clean -Xfd && pnpm install", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reset, before I learned rm -rf node_modules/.cache
was sufficient for testing turbo's cache
Uses: https://github.com/fox1t/turborepo-remote-cache
Start the daemon with
pnpm run daemon
(orpnpm exec pm2 start turborepo-remote-cache
).pnpm exec pm2 ls
This PR demonstrates running from source (storing locally) because I didn't feel like re-figuring out docker installation or deal with s3 credentials.
For real usage, if using a local daemon, the booting of the daemon should be abstracted in the scripts themselves. This is done here. This way, starting the daemon is not a separate command folks have to remember.
Two ways to test that this works:
with just one repo (easiest)
This demo doesn't represent distributed usage, but would demonstrate how you can save time in larger monorepos when you delete node_modules, and start from scratch. (but in this case, you don't need to actually re-build everything)
local-daemoned-cache
pnpm install
pnpm run build
-- these will all be "cache miss"node_modules/.cache
pnpm run build
-- these will all be "cache hit", as they are re-downloaded from the cache daemon. Without the daemon all packages will be "cache miss"with git worktrees (more realistic)
You will need two terminals
In Terminal 1
local-daemoned-cache
git worktree add -b daemon-2 ../tmp-limber-work-tree
pnpm install
set -a; source ./.env.turbo
to load the environment variablespnpm run daemon:status
shows the daemon as stopped, runpnpm run daemon
pnpm run build
-- these will all be "cache miss", but will store the built assets in the build cacheIn Terminal 2
tmp-limber-work-tree
pnpm install
set -a; source ./.env.turbo
to load the environment variablespnpm run build
-- this should show "FULL TURBO", as the cache was hit for all packagesYou can verify built assets exist now by
ls -la **/*/dist/
and verify again via
git clean -Xfd
,pnpm install
,pnpm run build
-> FULL TURBO -> dist assets all exist again.