Ordered Sequence of Commands for Starting/Stoping an Stack in OCI


Unless you are in containers/microservices (or other) architectures, typically you have several stacks consisting in (maybe three) layers, like front, mw and db. The idea here is how can I schedule an ordered and dependent sequence of commands for starting or stopping the stacks.

Start Sequence

Start sequence is typically bottom-up

#
# start db layer
#
oci db node start --db-node-id <dbnode1-ocid> --wait-for-state AVAILABLE
...
oci db node start --db-node-id <dbnoden-ocid> --wait-for-state AVAILABLE
#
# start mw's machines
#
oci compute instance action --action START --instance-id <vmnode1-ocid> --wait-for-state RUNNING
...
oci compute instance action --action START --instance-id <vmnoden-ocid> --wait-for-state RUNNING
#
# start front machines
#
oci compute instance action --action START --instance-id <vmnode1-ocid>
...
oci compute instance action --action START --instance-id <vmnoden-ocid>

Note the wait-for-state option that helps execute the stack in ordered sequence. Note not all the components need be in sequence, maybe several can be executed in “almost” parallel.

Stop Sequence

Stop sequence is typically up-down

#
# stop front machines
#
oci compute instance action --action STOP --instance-id <vmnode1-ocid>
...
oci compute instance action --action STOP --instance-id <vmnoden-ocid>
#
# stop mw's machines
#
oci compute instance action --action STOP --instance-id <vmnode1-ocid> --wait-for-state STOPPED
...
oci compute instance action --action STOP --instance-id <vmnoden-ocid> --wait-for-state STOPPED
#
# stop db layer
#
oci db node stop --db-node-id <dbnode1-ocid>
...
oci db node stop --db-node-id <dbnoden-ocid>

There are more commands depending on the component such as autonomous database, analytics cloud, etc.

That’s not all folks! Hope this helps đŸ™‚

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.