PreMiD is a decently large application. With just over 60 thousand users, it is a much larger feat to actually maintain the infrastructure that goes into running the website and application. This post is going to go through some of our strategies on how we deploy and keep all of our production servers in sync.
Let's discuss the website:
The website is a crucial part of PreMiD. It's the face of the application and contains all the information you'd want to know about PreMiD, and also includes the store. DePloY is our GitHub workflow that handles deploying both the website and the API. When we push to
masteror merge into
stable, the website is automatically deployed on https://beta.premid.app and https://premid.app respectively. Here's the steps:
- We SSH into the three servers that handle the website and API
cdinto the directory that has the guts of the website
- Run a
- Install with
- Build the website with
Lets talk about
pm2 reload for a second. Reloading and restarting with
pm2 is a very different operation. Reloading is a more graceful restart -- it takes down instances one by one and makes sure they start correctly before taking down the next one, and it keeps repeating this until your application is fully upgraded. This is a lifesaver when doing deployments, it means your application will remain running during an upgrade and even start serving new content whilst your old application is going down. The only time this may be an issue is if you have major changes between versions which may be incompatible and could lead to issues if both versions ran at the same time. If this is the case, we force a full restart on the deployment rather than a reload. However, this is such a rare occurrence that we never end up doing it.
The API is a very similar process. Identical, actually, except that instead of running
nuxt we're just running a standard Node application.
And that's it! Really! Our deployment process is kept relatively simple.
This is part of a series of Behind the Scenes posts. Make sure to check them out as we post them!