Skip to content

Commit abc60b4

Browse files
committed
docs: say to stop an extension before updating it
`update` deletes the old folder, so a running container would read deleted files and lose what it writes. The admin guide now says to run `stack down <id>` first and `stack up <id>` after, shows the sample output in its real order without a commit subject, and says that a shipped `.env` is not copied. ADR-022, the stack reference and the operator command map say the same, and describe the held Ctrl-C and the replaced `.source.toml`.
1 parent c71c652 commit abc60b4

4 files changed

Lines changed: 41 additions & 15 deletions

File tree

‎docs/admin-guide.md‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,6 +756,14 @@ If you do not give an id, `add` asks which extension to install. `add` never ins
756756

757757
> ⚠️ **Do not change the files that `add` installed.** If you change one of them, `update` stops for this extension. Files that you add to the folder are kept. To change the code of an extension, see [Extensions that you develop](#extensions-that-you-develop).
758758
759+
> ⚠️ **Stop a running extension before you update it.** `update` deletes the old folder. A running container then reads deleted files, and the files that it writes during the update are lost.
760+
761+
To stop the extension, run:
762+
763+
```bash
764+
./stack down hue
765+
```
766+
759767
To update all extensions that you installed with `add`, run:
760768

761769
```bash
@@ -771,27 +779,27 @@ To update one extension, give its id:
771779
`update` gets the newest version of each extension from the default branch of its repository. This is the version that `./stack extensions list` compares with. Extensions from the same repository share one download. Each extension then gets one line:
772780

773781
```
774-
Fetching https://github.com/famstack-dev/famstack-extensions...
775782
toaster installed by hand, not updated
776-
✓ hue updated to 3c9d2f1 "feat(hue): switch scenes"
783+
Fetching https://github.com/famstack-dev/famstack-extensions...
784+
✓ hue updated to 3c9d2f1
777785
Apply the new code with: stack up hue
778786
web up to date
779787
```
780788

789+
`updated to` shows the newest commit of the repository. This commit can be a change to a different extension.
790+
781791
**What `update` does:**
782792

783793
1. It compares the installed version with the newest version in the repository. If they are the same, the extension is **up to date**. A change to a different extension of the same repository is not an update.
784794
2. It checks the files that `add` or the last `update` wrote. `.source.toml` records each of these files. If one of them is changed or missing, `update` stops for this extension.
785-
3. It writes the new version into `~/famstack-extensions/.incoming/`.
795+
3. It writes the new version into `~/famstack-extensions/.incoming/`. It does not copy a `.env` file that the repository contains, because `./stack up` writes this file.
786796
4. It checks the files again, in case they changed while `update` asked a question.
787797
5. It moves all other files of the old folder into the new version. For example, it keeps the `.env` file that `./stack up` writes. It also keeps a configuration file that the README asks for. If the new version has a folder with the same name as your folder, `update` moves your files into it.
788798
6. It puts the new folder in the place of the old folder. Then it deletes the old folder.
789799

790-
If a step fails, `update` puts the old folder and your files back. If it cannot put a file back, the message shows where the file is.
791-
792-
> ⚠️ **Run `./stack up <id>` immediately after an update.** A running extension continues to use the old files until you start it again.
800+
If a step fails, `update` puts the old folder and your files back. If it cannot put a file back, the message shows where the file is. If you press Ctrl-C while `update` moves files, it completes the move first and then stops.
793801

794-
To start the extension with the new code, run:
802+
`update` does not start the extension. To start it with the new code, run:
795803

796804
```bash
797805
./stack up hue

‎docs/adr/adr-022-extensions-are-copied-from-a-repo.md‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,13 @@ admin.
107107
The strings in `.source.toml` are TOML basic strings. A file name outside ASCII
108108
is written as it is, and control characters are escaped. When the source is a
109109
local directory, `add` records its absolute path. Because of this, `update`
110-
finds it from each working directory.
110+
finds it from each working directory. `add` does not resolve symlinks in the
111+
path, because a catalog configured through a symlink must still match.
112+
113+
The copy leaves out a `.env` at the root of the extension and does not record
114+
it, because `stack up` writes this file on each start. The copy also removes a
115+
`.source.toml` that the repository ships, before it writes its own. A shipped
116+
symlink would otherwise send the record to a file outside the folder.
111117

112118
### 4. The catalog is a configuration key
113119

@@ -199,9 +205,17 @@ does not change it. The invariant: `update` deletes only files that `add` or
199205
includes Ctrl-C. When that fails too, the message names the path in
200206
`.incoming/`. `update` never deletes a staging folder that holds a kept
201207
file.
202-
- `update` starts nothing. For an extension that is set up, it shows
203-
`stack up <id>`. `stack up` recreates the containers and the bot runner.
204-
`stack restart` does not reload the bot runner.
208+
- `add` and `update` hold back Ctrl-C while files move and folders swap.
209+
They raise it after the swap is complete. A hard stop, such as a power
210+
cut, is not covered.
211+
- `update` starts nothing and stops nothing. For an extension that is set
212+
up, it shows `stack up <id>`. `stack up` recreates the containers and the
213+
bot runner. `stack restart` does not reload the bot runner.
214+
- The admin stops a running extension before the update. A running
215+
container reads the deleted old folder, and loses what it writes there.
216+
- The line for an updated extension names the newest commit of the
217+
repository only, because the clone is shallow. It does not know the last
218+
commit that changed the extension.
205219
- A refusal of one extension does not stop the others. The exit code is 1
206220
when `update` refused one.
207221

‎docs/agent/ops.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ If a precondition is missing, `./stack` prints exactly what to do. Don't improvi
3838
| `./stack update [<tag>]` | yes | no | moves the checkout to a release; restarts nothing, prints what to restart |
3939
| `./stack extensions list` | yes | no | the catalog's extensions and what is installed; creates no extension dir |
4040
| `./stack extensions add <id\|git-url> [<id>]` | refuses a second time | no | copies one extension into the first extension dir and starts nothing; warns first for any repo but the catalog (`--yes` skips only the question) |
41-
| `./stack extensions update [<id>...]` | yes | no | replaces installed extensions with the newest version on their repo's default branch; keeps every file it did not write (`.env`, local config), refuses when a file it wrote was changed, starts nothing (`stack up <id>` applies it); warns first for any repo but the catalog (`--yes` skips only the question) |
41+
| `./stack extensions update [<id>...]` | yes | no | replaces installed extensions with the newest version on their repo's default branch; keeps every file it did not write (`.env`, local config), refuses when a file it wrote was changed, stops and starts nothing (`stack down <id>` first, `stack up <id>` after); warns first for any repo but the catalog (`--yes` skips only the question) |
4242
| `./stack list` | yes | no | reports state |
4343
| `./stack status` | yes | no | runs health checks |
4444
| `./stack logs <id>` | yes | no | tail container logs |

‎docs/stack-reference.md‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,13 @@ first extension dir, when it installs an extension there.
6363
the newest version of its path, on the default branch of the repository.
6464
It refuses when a file in `[files]` is changed or missing.
6565
- `update` moves each file that is not in `[files]` into the new version,
66-
for example `.env`. It never deletes such a file, also when a step fails. It writes the new version into `.incoming/` of the
67-
same extension dir and swaps the folders with two renames. It starts
68-
nothing: `stack up <id>` applies the new code.
66+
for example `.env`. It never deletes such a file, also when a step fails.
67+
It writes the new version into `.incoming/` of the same extension dir and
68+
swaps the folders with two renames, with Ctrl-C held back. It starts
69+
nothing: `stack up <id>` applies the new code. Stop a running extension
70+
first, because the old folder is deleted.
71+
- The copy leaves out a `.env` at the root of the extension and replaces a
72+
shipped `.source.toml`.
6973
- Discovery reads the folder like any other stacklet folder.
7074
- `stack extensions` never changes a folder without `.source.toml`. Such a
7175
folder was put there by hand. `update` refuses a `.source.toml` without

0 commit comments

Comments
 (0)