Summary#
A local platform is created per project, on demand, and each one carries a full database of its own — a few hundred megabytes. Over a few weeks of ordinary work that is tens of gigabytes of projects you have long since moved on from. This deletes the ones that are no longer in use, and tells you first.
Signature#
osy instances --prune [--yes] [--stale] [--idle-hours <n>] [--json]Description#
It is a dry run unless you pass --yes. On its own it prints what it would delete, what that would reclaim, and —
just as usefully — everything it is KEEPING, with the reason for each. Read it, then re-run with --yes.
An instance is deleted when nothing is running on it — a platform whose server is up or still starting is never touched, and neither is one whose state cannot be established; if it cannot be shown that nothing is running, it stays — and either of these is true:
- its project is gone, or it never recorded one. Nothing will start a server for it again, so it goes at once, however recently it was used.
- it has not been used recently. Two hours, by default;
--idle-hourschanges the window.
--stale narrows the prune to instances whose project directory no longer exists — not the ones that never recorded
a project, and not old instances of projects you still have.
A platform you launched to use is kept. One you opened with Launching your app or
Opening Studio holds what you put into it — the rows you seeded, the accounts you signed up — and is not
a cache in the same sense. So an instance opened that way and used in the last day is kept by every cleanup:
--prune at any --idle-hours (0 included), the reaping a start does, and the disk-pressure eviction below. A
prune lists these on their own, each as kept: launched for use, used <when>, with the command that deletes it. Once
it has gone a day unused, or its project directory is gone, it is treated like any other instance.
To delete one instance, name it from its project. osy stop --delete stops this project's local platform and then
deletes its instance — the database with it. It only ever deletes this project's: a --devname that names another
project's instance is refused, naming that project, and an instance that is still running after the stop is refused
too. This is how a launched-for-use platform is deleted, and how a script that runs tests in many projects leaves
none behind.
Note what does not keep an instance: its project still existing. A checkout can live for months while you start platforms in it several times a day, so keeping every instance of every live project would keep almost all of them. A local platform is disposable by design — rebuilt from your source whenever a command needs one — so deleting one costs a rebuild and nothing else. Nothing you would miss is stored there; your app's real data lives on the platform you deploy to.
Everyday use needs none of this: starting a local platform reaps unused ones as it goes, by the same rule, and each instance keeps at most 20 MB of logs, dropping the oldest first. The command is for when you want to see the number, or clear space now.
When the disk runs low, starting a platform makes room first. A database that runs out of disk stops in the middle of whatever it was doing, so a local platform keeps 5 GB free on the disk that holds its instances. If there is less, starting one deletes stopped instances, the least recently used first, however recently they were used, until there is 5 GB free again. A running instance is never deleted, and neither is the one being started, nor one launched for use in the last day. If there is still less than 1 GB free after that, the platform does not start, and the message says how much space is free — and, when what is left is a platform launched for use, names it with the command that deletes it, so the choice of deleting it stays yours.
If a database does fail during osy test, the summary under the results quotes what the database's own log says
about it, such as a full disk. The tests that failed after that point tell you nothing about your app.
Listing your local platforms reports the total on disk every time you run it, so the figure is visible long before it is a problem.
Examples#
osy instances --prune # what would go, and what stays — deletes nothingosy instances --prune --yes # actually delete themosy instances --prune --idle-hours 0 --yes # everything that is not running, nowosy instances --prune --stale --yes # only the ones whose project is goneosy stop --delete # stop this project's platform and delete its instanceSee also#
Listing your local platforms — what is on this machine, which are running, and how much disk it all takes.
Stopping the local platform — stop one that is running, so it becomes a candidate, or delete it with --delete.
Launching your app — the command whose platforms cleanup keeps for a day.
The inner loop — where local platforms come from in the first place.