siniradam
siniradam

Reputation: 2929

How to distinguish servers in node js with a unique server property/value?

I have a project currently works on a single server. Now more regions will be added, and I update server files via private git repository, but each has a different configuration (like database connections) I want to be able to access a unique server value (maybe mac address?) to distinguish servers so corresponding settings file can be loaded. Servers are ubuntu.

What is the best practice? I tried os.hostname() but it is not unique (usually like: ubuntu-fra-8gb) Or should I just go with ENV values?

Upvotes: 0

Views: 37

Answers (1)

Daniele Ricci
Daniele Ricci

Reputation: 15797

A good option is to provide an instanceName to the server through command line parameters or environment variables when you launch it; than using that name as configuration key.

Hope this helps.

Upvotes: 1

Related Questions