How to power down GitHub Codespaces?
Asked Answered
S

2

12

How can one shutdown GitHub Codespaces to avoid extra costs?

Sixfooter answered 1/9, 2021 at 13:52 Comment(0)
F
14

From the Command Palette you can explicitly stop a codespace:

enter image description here

You can access that quickly from the >< Codespaces option in the status bar.

And other options to stop a codespace from the official docs:

Closing or stopping your codespace

Your codespace will keep running while you are using it, but will time out after a period of inactivity. File changes from the editor and terminal output are counted as activity, so your codespace will not time out if terminal output is continuing. The default inactivity timeout period is 30 minutes. You can define your personal timeout setting for codespaces you create, but this may be overruled by an organization timeout policy. For more information, see "Setting your timeout period for GitHub Codespaces."

If a codespace times out it will stop running, but you can restart it from the browser tab (if you were using the codespace in the browser), from within VS Code, or from your list of codespaces at https://github.com/codespaces.

To stop your codespace you can

  • In the browser: on your list of codespaces at https://github.com/codespaces, click the ellipsis (...) to the right of the codespace you want to stop and click Stop codespace.
  • In VS Code: open the Visual Studio Code Command Palette - for example, by pressing Ctrl+Shift+Enter(Windows/Linux) or Shift+Command+P (Mac) - type Codespaces: stop then press Enter.
  • In the JetBrains client, click the stop button at the top of the GitHub Codespaces tool window. For more information, see the "JetBrains IDEs" tab of "Stopping and starting a codespace."
  • In a terminal window: use the GitHub CLI command gh codespace stop. For more information, see "Using GitHub Codespaces with GitHub CLI." If you exit your codespace without running the stop command (for example, by closing the browser tab), or if you leave the codespace running without interaction, the codespace and its running processes will continue for the duration of the inactivity timeout period.

When you close or stop your codespace, all uncommitted changes are preserved until you connect to the codespace again.

Fish answered 20/9, 2021 at 10:12 Comment(0)
P
6

First, about the "to avoid additional costs" part: It's not enough to stop a codespace. This will prevent your "usage hours" from increasing, but the stopped codespace will continue to eat up your monthly storage. Remember: you have a limit of 60 hours (minimum configuration with 2 cores usage) and a storage limit of 15 GB per month ( as of November 2022). You can have multiple "stopped" codespaces waiting to be continued, all using up your monthly storage.

To prevent this, you must not only stop a codespace, but also delete it. You can always create a new codespace based on the current state of your repository.

Reusing existing codespaces boils down to a choice of work habits. Do you have pending code changes that you don't want to commit yet? Then keep your codespace alive, come back later, and finish your work. With a single codespace in a small repository, this is not a problem. But if you have multiple codespaces, maybe even with prebuilds, then you should keep your limits in the eye.

That said, here are ways to stop codespaces:

  • From within the codespace, you can stop it from the Codespaces Button in the bottom left corner in the status bar as in the Answer from @jessehouwing .
  • On the repositorys GitHub page, you can stop (and / or delete) your codespaces running on this repository via the green [Code] Button. First go from [Local] to [Codespaces], then use the [...] Menu. First go from [Local] to [Codespaces], then use the [...] Menu.
  • You can see all of your codepaces in your Github Account by selecting [Codespaces] in the topmost menubar of the Github-Site. Again, use the [...] menu to close or delete the Codespace.
  • if you have Github Cli installed, you can stop codespaces with the gh codespace stop command. You need to provide the name of the codespace, which you can get with gh codespace list.
  • The easiest way to completely delete all of your current workspaces is by calling gh codespace delete --all in Github Cli. (The --all option isn't available for the stop command, so you always need to specify a name then)
Plataea answered 8/12, 2022 at 20:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.