JLCDev
JLCDev

Reputation: 629

How to delivery new code version into several node.js servers?

We have some node.js servers hosted by google cloud compute engine. As the instances running the servers are created by an Instance Group there is a Load Balancer in front of them and their IP change frequently.

When the Instance Group creates the instance from the Instance Templates, the boot script pulls the current version using gitlab and the process runs ok.

Is there a way to upload versions in all instance group using a single command line, something that could make all the instances run git pull initiated by centralised requests?

Upvotes: 2

Views: 54

Answers (1)

GalloCedrone
GalloCedrone

Reputation: 5075

There are multiple ways to do so, but I see two straightforward solutions to your problem depending on your needs:

  1. Since you are running the servers on a Linux instance is to setup a cronjob at startup time that from that moment on with the frequency you prefer pull the code from your repository through the classical git pull.

    This solution is not extremely elegant, but few lines are needed and it is quite effective. Obviously if check the new code each T seconds the servers risk to run different code for at maximum for T seconds, this depending on the nature of your workload might be an issue.

  2. There is a built in features to do so, the Repository Mirroring. Your mirror at GitLab will be updated automatically. Honestly I have never implemented this solution, but you can check the following StackOverflow answer that could guide you through the process.

Upvotes: 1

Related Questions