ronivay / XenOrchestraInstallerUpdater

Xen Orchestra install/update script
GNU General Public License v3.0
1.21k stars 190 forks source link

Clean yarn cache after build #182

Closed hoerup closed 1 year ago

hoerup commented 1 year ago

The yarn cache can accumulate several gigs of packages (on my system it's saved in /usr/local/share/.cache/yarn/ )

Add an option to do a yarn cache clean after install is done

dsiminiuk commented 1 year ago

Wow!

/usr/local/share/.cache/yarn/v6/ has 7,865 files, almost 7 GB disk space.

root@xo# yarn cache clean
yarn cache v1.22.19
success Cleared cache.
Done in 46.17s.

Now 0 files.

In the meantime this will be a cron job.

Thanks @hoerup !

ronivay commented 1 year ago

This is a good idea indeed. Might slow down updates a bit (due to empty cache) but can be made optional in config. I'll look into this soonish.

dsiminiuk commented 1 year ago

@ronivay Only the first time. Then it won't take long between updates.

ronivay commented 1 year ago

Well yeah but if i'm implementing a config option to empty cache, it'll be run after each install/update so essentially cache will always be empty when running update.

hoerup commented 1 year ago

The best would imho be if yarn could be configured to only cache the latest version of a package instead of accumulating all previously used versions - but that doesn't seem to be the case. Nor is there any kind of LRU settings that can be used for auto-eviction.

So a optional post-install yarn cache clean would be the next-best thing to limit the space consumed by the cache.

github-actions[bot] commented 1 year ago

This issue has been open for 14 days without activity. It will be closed in 5 days if not updated

vmpr commented 1 year ago

that would be a great feature! I just cleared my yarn cache as my server run out of space :)

dsiminiuk commented 1 year ago

I used a wrapper script to call the updater already, so I added just the yarn clear cache command at the end. It would be a "nice to have" if it were built in, but there are work-arounds to automate it.

For example, this is the content of the email I get after an update.

Checking current node.js version node.js version already on 18, checking updates Fetching Xen Orchestra source code Creating install directory: /etc/xo/xo-builds/xen- orchestra -202304290145 Updating Xen Orchestra from 'c0465eb4d' to 'fd2c7c2fc' No 3rd party plugins to install Running installation Installing plugins Shutting down running xo-server Fixing binary path in systemd service configuration file Adding WorkingDirectory parameter to systemd service configuration file Replacing systemd service configuration file Reloading systemd configuration Fixing relative path to xo-web installation in xo-server configuration file Changing redis connection address in xo-server configuration file Activating modified configuration file Symlinking fresh xo-server install/update to /etc/xo/xo-server Symlinking fresh xo-web install/update to /etc/xo/xo-web Symlinking fresh xo-cli install/update to /etc/xo/xo-cli Symlinking xo-cli script to /usr/local/bin/xo-cli Starting xo-server... Update successful. Enabling xo-server service to start on reboot Removing old inactive installations after update. Leaving 2 latest Cleaning yarn cache... yarn cache v1.22.19 success Cleared cache. Done in 11.45s. For changes in this commit see https://github.com/vatesfr/xen-orchestra/commit/fd2c7c2fc

ronivay commented 1 year ago

YARN_CACHE_CLEANUP boolean config option now implemented which will run cleanup after an update if set to true. Defaults to false