generator-angular-fullstack icon indicating copy to clipboard operation
generator-angular-fullstack copied to clipboard

Best Practice for updating application in production environment

Open molerat619 opened this issue 8 years ago • 7 comments

I have successfully launched an angular-fullstack application and especially at the beginning there are quite frequent small updates I want to make to the system. What is the best practice to do it?

Right now, this is what I do:

  1. SSH into ubuntu server
  2. Go to application's root directory
  3. git pull
  4. stop the server
  5. grunt build
  6. start the server in production mode

So during between step 4 and step 6, the server is down. This might not be the best way to do it.

Also, how do you handle 503 here? For SEO it is beneficial if you tell Google that the server is not available only temporarily.

Thanks for your help!

Edit: I know you can automate the steps with a continuous deployment server. But again - the downtime is there.

molerat619 avatar Jun 06 '17 13:06 molerat619

If you're looking for a zero-downtime solution, you're probably going to have some work ahead. I run most of my web apps in Docker containers with at least two replicas, so that I can do a rolling update. I have a load balancer in front of both, and when one goes down, traffic goes to the other. Then the first comes back up with the new version, and can receive traffic again. Then the same goes for the other replica. I personally do all this with Kubernetes, but I'm sure that's out of the scope for what you're looking for. IIRC Heroku might offer a service to do something like this for you.

Awk34 avatar Jun 06 '17 15:06 Awk34

Thank you, I think that is a very good solution, but seems a bit overkill for my case at this stage. I plan to do this in the long run though.

Any other ideas? Maybe some quick-wins?

molerat619 avatar Jun 06 '17 16:06 molerat619

How far do you want to go? My first suggestion would be to start using a continuous integration system. My favorite is CircleCI. You just need it to run your tests, run a build, and then package it and send it somewhere.

Awk34 avatar Jun 06 '17 18:06 Awk34

You can create a production repo @molerat619 so you can gulp/grunt build on your local and push it to your production repo.

Then on your server only git pull && npm install and restart the server. This could avoid the downtime on your server while doing gulp/grunt build

drochag avatar Jun 06 '17 20:06 drochag

@Awk34 Continouus Integration is also pretty cool. Definitely going to do that too. I used shippable and Jenkins so far - in my case both were free.

@DanMMX that's actually a good idea. For the small down time - do you know how that 503 could work with angular-fullstack? I also have Apache running on the ubuntu server.

molerat619 avatar Jun 07 '17 11:06 molerat619

@DanMMX The solution you are referring to would involve version controlling dist folder in the same git repository. Would it be possible to have two different repos one for source and one for dist.

samsfisher avatar Jul 24 '17 23:07 samsfisher

@samsfisher It shouldn't necessarily be the same repository, what I do is git clone original dev && cd dev git clone production dist

So the dist folder is another repo and add it to the .gitignore from the parent repo

drochag avatar Jul 25 '17 22:07 drochag