What does your build pipeline look like?

github logo ・1 min read

How does your code go from the repo to the users? How do you deal with connection draining? Do you make sure that requests using the old code aren't interrupted? Do you spin servers up and down based on load? Do you have websocket connections that can last for hours?

twitter logo DISCUSS (2)
markdown guide
 

Right now I use Jenkins. I can select a group of servers and kick off an Ansible task. That will set up the servers. It will pull down new code from an in house Gitlab. If the Git revision has changed the build will start. It will build the code using NPM and rsync it to the web directory deleting the old build after the sync is complete.

The app is a SPA app. The problem with that is that users will stay on the old version of they app if they don't refresh their page. After the frontend code is deployed a key is updated in the cache. That key is placed in the headers of every respsonse from the backend. Each AJAX request checks the header. If the header changes it means new code was deployed. The next time the user changes routes we do window.location.reload() and they start using the new site.

The Ansible process continues running. I have two sets of 8 services. One set is always in live mode and the other is in drain mode. During a deployment they switch. One set of the 8 processes will restart with the new code and the other 8 will start draining. The draining is accomplished by sending the requests through HAProxy. HAProxy has a built in drain feature. There are websocket connections involved so the connections could last for hours. This lets all new requests use the new code and old requests don't get interrupted.

Theres no Docker or Kubernetes but it works for me. I'm sure I'll move over to something Docker based eventually. Draining websockets has always been the big sticking point.

 

For the backend applications, I have a deploy script which builds my app and deploys it to relevant servers.

For the frontend applications, I use Stormkit. PS: I wrote it :P

Classic DEV Post from Oct 4 '18

What is your best advice for a junior software developer?

What is your best advice for a junior software developer?

Kyle Agronick profile image
Full stack developer. Mainly Django and Vue these days.
  1. Read Post πŸ€“
  2. Follow Author πŸ‘‹
  3. Profit??? πŸ€”