Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get app-engine's current instance id in node.js

Is there any way to get the current instance id from app-engine in node.js?

I found solutions only for java and python but nothing for node.

like image 278
Michele Pini Avatar asked May 06 '16 08:05

Michele Pini


People also ask

What is Node JS instance?

Node. js is an open source server environment. Node. js allows you to run JavaScript on the server.


1 Answers

As there's no traditional App Engine runtime for nodejs, I'm assuming you're using Flexible Environment (AKA "Custom Runtimes"). In such a case, you can read in the docs that using the Compute Engine Metadata Server can provide the information you're looking for. Custom Runtime / Flex apps are actually running in a Docker container on a Compute Engine VM. The docs say:

Each instance of your application can use the Compute Engine metadata server to query information about the instance, including its host name, external IP address, instance ID, custom metadata, and service account information. App Engine does not allow you to set custom metadata for each instance, but you can set project-wide custom metadata and read it from your App Engine and Compute Engine instances.

Cheers!

like image 138
Nick Avatar answered Sep 22 '22 03:09

Nick