Stop an instance when you don’t need it running. A stopped instance accrues no compute usage, and it keeps its volumes, network interface and addresses. Start it again when you need it, the same instance, possibly on a different machine.
Before you begin
Stop the instance
-
Request the stop:
terminal origin compute stop-instance --instance-urn <instance-urn>The platform asks the guest operating system to shut down cleanly. A guest that hasn’t shut down after 5 minutes is powered off.
-
Run
get-instanceuntilstatusreadsSTOPPED:terminal origin compute get-instance --instance-urn <instance-urn>The instance passes through
STOPPINGfirst.
You can also shut the guest down from inside, with sudo poweroff. The instance then goes from RUNNING straight to STOPPED.
Start the instance
-
Request the start:
terminal origin compute start-instance --instance-urn <instance-urn> -
Run
get-instanceuntilstatusreadsRUNNING. The instance passes throughPENDINGfirst. -
Verify that the guest is up. Its
healthChecks.availabilityreadsAVAILABLEonce the platform has seen its network stack answer. See Instance health checks.
Starting an instance that is already RUNNING reports success and changes nothing. Starting one that is still PENDING re-sends the start it is waiting for, without disturbing a guest that is coming up. A start is refused while the instance is INITIALIZING, because it starts on its own once its resources are ready, and while it is STOPPING or SHUTTING_DOWN.
Using the API
The startInstance and stopInstance mutations take the instance URN:
mutation {
compute {
stopInstance(input: { instanceUrn: "<instance-urn>" }) {
accepted
message
}
}
}If this fails
- The start is refused with
PRODUCT_UNAVAILABLE. The instance’s type is no longer offered. Change it to an available type, then start it. See Change an instance’s type. - The start is refused with
INSUFFICIENT_CAPACITY. A stopped instance is placed afresh when it starts.INSUFFICIENT_No host has room for this type right now. Retry in a few minutes; a larger type may have room. gp1.core.2 is the smallest type, so there is no smaller one to try. To try a larger type, change the instance’s type first. See Change an instance’s type.CAPACITY - The instance ends up
FAILED. Read itsstatusReason. See When a lifecycle operation fails.