Skip to content

Zero Downtime deployment for different app version

nginx-c-function edited this page Oct 16, 2018 · 10 revisions

1. Located your built program .so application, if you have no any idea of this, please refer to this Sample Application

2. Assumed that your application called "myApp-1.0.0.so" which located at "/etc/nginx/apps/myApp-1.0.0.so", then go to nginx and add one the content below

server {
  listen 8888;
  ...
  ngx_http_c_func_link_lib "/etc/nginx/apps/myApp-1.0.0.so";
  ...
  ...
  location = /testCFunGreeting {
      # if not variable specified, direct write response out
      ngx_http_c_func_call "my_app_simple_get_greeting"; 
  }
}

3. Then start the nginx.

4. Somehow you have built new version of your application, then you named it as "myApp-2.0.0.so" which you stored it at "/etc/nginx/apps/myApp-2.0.0.so", then please go to nginx and change the content below

from ngx_http_c_func_link_lib "/etc/nginx/apps/myApp-1.0.0.so"; to ngx_http_c_func_link_lib "/etc/nginx/apps/myApp-2.0.0.so";

5. then reload nginx by sudo nginx -s reload

6. Congratulation! you have just done the zero deployment. Now you can safely backup/archive/delete your old version of your app.

## 7. Caution! Please do not direct overwrite the new .so application to current one while nginx is running, it will crash the nginx module, please follow step 1 to 6 to achieve the deployment

Clone this wiki locally