Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect google compute instance startup script finished?

In Google Compute Engine, when starting a virtual machine, an operation is created. When the operation is done, the virtual machine is ready (or the operation could have a failed status). However, my startup script (specified via startup-script-url) is still running after a successful insert operation.

Is there a way to detect using the compute api?

I'm using the googleapis node library which is basically a wrapper around the official Compute Api (https://developers.google.com/apis-explorer/#p/compute/v1/).

When I'm doing this manually, I just keep an eye on the serial console.

like image 595
Jaap Avatar asked Jan 20 '16 14:01

Jaap


People also ask

Where are startup scripts stored?

Startup scripts stored locally or added directly execute before startup scripts that are stored in Cloud Storage. The type of file containing the script also impacts the order of execution. The following table shows, based on the metadata key, the order of execution of Windows startup scripts.

How do I find the startup script in Linux?

During the boot process the init process looks in the /etc/inittab file to find the default runlevel. Having identified the runlevel it proceeds to execute the appropriate startup scripts located in the /etc/rc. d sub-directory.

What are the tasks performed by startup script?

Stay organized with collections Save and categorize content based on your preferences. A startup script is a file that contains commands that run when a virtual machine (VM) instance boots.


1 Answers

Not sure if this would work, but you could let your startup script add a tag to its host once it's done: https://cloud.google.com/sdk/gcloud/reference/compute/instances/add-tags

Then you could poll calls to describe: https://cloud.google.com/sdk/gcloud/reference/compute/instances/describe

Once you see the tag added there your script should be done.

like image 66
Christiaan Avatar answered Oct 11 '22 05:10

Christiaan