ZiiMakc
ZiiMakc

Reputation: 36946

Run script only on main jelastic node

Is there a way to determinate that this node.js node is main using environment variables?

server.js

if (process.env === 'main') runSmth()

In docs i found only:

MASTER_ID - A unique node identifier of a master node within a layer.

But i suppose it's the same for every node. And i did not found node_if variable :(

Upvotes: 1

Views: 113

Answers (1)

Ruslan
Ruslan

Reputation: 395

Example of bash condition to find out if script is running on the master node:

[[ $(hostname -s) == $MASTER_HOST* ]] && { 
  echo "It's the MASTER"; 
} || { 
  echo "It's NOT the MASTER"; 
}

Upvotes: 1

Related Questions