mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-04-13 09:42:01 +00:00
Blue green deploy, doesn't work yet.
This commit is contained in:
parent
54c60c1a23
commit
c0c7a2f2de
6 changed files with 68 additions and 18 deletions
|
@ -119,21 +119,68 @@
|
||||||
tags:
|
tags:
|
||||||
- static
|
- static
|
||||||
|
|
||||||
- name: Reload gunicorn due to no git upstream changes
|
- name: Run new Docker container with temporary name
|
||||||
become: yes
|
docker_container:
|
||||||
block:
|
name: "newsblur_web_new"
|
||||||
- name: Find gunicorn process
|
image: "newsblur/newsblur_web:latest"
|
||||||
shell: "ps -C gunicorn fch -o pid | head -n 1"
|
pull: true
|
||||||
register: psaux
|
state: started
|
||||||
- name: Reload gunicorn
|
restart_policy: always
|
||||||
command: "kill -HUP {{ psaux.stdout }}"
|
command: "gunicorn newsblur.wsgi:application --bind :8000 --workers 4"
|
||||||
# Only restart if there were no changes to the git repo or the static tag was applied
|
hostname: "newsblur_web_new"
|
||||||
when: not pulled.changed or "'static' in ansible_playbook_tag"
|
networks:
|
||||||
rescue:
|
- name: newsblur-network
|
||||||
- name: Restart Docker Container
|
ports:
|
||||||
command: "docker restart newsblur_web"
|
- "8001:8000" # Use different port for new instance
|
||||||
tags:
|
volumes:
|
||||||
- static
|
- /srv/newsblur:/srv/newsblur
|
||||||
|
- /etc/nginx/sites-enabled:/etc/nginx/sites-enabled
|
||||||
|
- /etc/nginx/sites-available:/etc/nginx/sites-available
|
||||||
|
- /srv/secrets-newsblur:/srv/secrets-newsblur
|
||||||
|
|
||||||
|
- name: Wait for new temp container to be healthy
|
||||||
|
uri:
|
||||||
|
url: "http://localhost:8001/api/health-check" # Add health check endpoint
|
||||||
|
status_code: 200
|
||||||
|
validate_certs: no
|
||||||
|
register: result
|
||||||
|
retries: 10
|
||||||
|
delay: 5
|
||||||
|
until: result.status == 200
|
||||||
|
|
||||||
|
- name: Run new Docker container with original name
|
||||||
|
docker_container:
|
||||||
|
name: "newsblur_web"
|
||||||
|
image: "newsblur/newsblur_web:latest"
|
||||||
|
pull: true
|
||||||
|
state: started
|
||||||
|
restart_policy: always
|
||||||
|
command: "gunicorn newsblur.wsgi:application --bind :8000 --workers 4"
|
||||||
|
hostname: "newsblur_web"
|
||||||
|
networks:
|
||||||
|
- name: newsblur-network
|
||||||
|
ports:
|
||||||
|
- "8000:8000"
|
||||||
|
volumes:
|
||||||
|
- /srv/newsblur:/srv/newsblur
|
||||||
|
- /etc/nginx/sites-enabled:/etc/nginx/sites-enabled
|
||||||
|
- /etc/nginx/sites-available:/etc/nginx/sites-available
|
||||||
|
- /srv/secrets-newsblur:/srv/secrets-newsblur
|
||||||
|
|
||||||
|
- name: Wait for new original container to be healthy
|
||||||
|
uri:
|
||||||
|
url: "http://localhost:8000/api/health-check"
|
||||||
|
status_code: 200
|
||||||
|
validate_certs: no
|
||||||
|
register: result
|
||||||
|
retries: 10
|
||||||
|
delay: 5
|
||||||
|
until: result.status == 200
|
||||||
|
|
||||||
|
- name: Stop and remove temp Docker container
|
||||||
|
docker_container:
|
||||||
|
name: "newsblur_web_new"
|
||||||
|
state: absent
|
||||||
|
|
||||||
- name: Start Consul
|
- name: Start Consul
|
||||||
become: yes
|
become: yes
|
||||||
|
|
|
@ -54,7 +54,7 @@
|
||||||
- /etc/hosts:/etc/hosts
|
- /etc/hosts:/etc/hosts
|
||||||
with_items:
|
with_items:
|
||||||
- container_name: "task-celery"
|
- container_name: "task-celery"
|
||||||
command: "celery worker -A newsblur_web --loglevel=INFO -Q new_feeds,push_feeds,update_feeds,search_indexer,discover_indexer"
|
command: "celery worker -A newsblur_web --loglevel=INFO -Q discover_indexer,search_indexer,new_feeds,push_feeds,update_feeds"
|
||||||
when: "{{ inventory_hostname == 'htask-celery-10' }}"
|
when: "{{ inventory_hostname == 'htask-celery-10' }}"
|
||||||
- container_name: "task-celery"
|
- container_name: "task-celery"
|
||||||
command: "celery worker -A newsblur_web --loglevel=INFO -Q new_feeds,push_feeds,update_feeds,search_indexer"
|
command: "celery worker -A newsblur_web --loglevel=INFO -Q new_feeds,push_feeds,update_feeds,search_indexer"
|
||||||
|
|
|
@ -25,7 +25,6 @@ forwarded_allow_ips = "*"
|
||||||
limit_request_line = 16000
|
limit_request_line = 16000
|
||||||
limit_request_fields = 1000
|
limit_request_fields = 1000
|
||||||
worker_tmp_dir = "/dev/shm"
|
worker_tmp_dir = "/dev/shm"
|
||||||
reload = True
|
|
||||||
|
|
||||||
workers = max(int(math.floor(GIGS_OF_MEMORY * 2)), 3)
|
workers = max(int(math.floor(GIGS_OF_MEMORY * 2)), 3)
|
||||||
|
|
||||||
|
|
|
@ -183,6 +183,7 @@ backend staging
|
||||||
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
|
default-server check inter 2000ms resolvers consul resolve-prefer ipv4 resolve-opts allow-dup-ip init-addr none
|
||||||
{% for host in groups.staging %}
|
{% for host in groups.staging %}
|
||||||
server {{host}} {{host}}.node.nyc1.consul:8000
|
server {{host}} {{host}}.node.nyc1.consul:8000
|
||||||
|
server {{host}} {{host}}.node.nyc1.consul:8001 backup
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
backend blog
|
backend blog
|
||||||
|
|
|
@ -113,16 +113,19 @@ backend app_django_counts
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
option httpchk GET /_haproxychk
|
option httpchk GET /_haproxychk
|
||||||
server app_django 127.0.0.1:8000 check inter 3000ms
|
server app_django 127.0.0.1:8000 check inter 3000ms
|
||||||
|
server app_django_backup 127.0.0.1:8001 check inter 3000ms backup
|
||||||
|
|
||||||
backend app_django_refresh
|
backend app_django_refresh
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
option httpchk GET /_haproxychk
|
option httpchk GET /_haproxychk
|
||||||
server app_django 127.0.0.1:8000 check inter 3000ms
|
server app_django 127.0.0.1:8000 check inter 3000ms
|
||||||
|
server app_django_backup 127.0.0.1:8001 check inter 3000ms backup
|
||||||
|
|
||||||
backend app_django
|
backend app_django
|
||||||
balance roundrobin
|
balance roundrobin
|
||||||
option httpchk GET /_haproxychk
|
option httpchk GET /_haproxychk
|
||||||
server app_django 127.0.0.1:8000 check inter 3000ms
|
server app_django 127.0.0.1:8000 check inter 3000ms
|
||||||
|
server app_django_backup 127.0.0.1:8001 check inter 3000ms backup
|
||||||
|
|
||||||
backend maintenance
|
backend maintenance
|
||||||
option httpchk HEAD /maintenance
|
option httpchk HEAD /maintenance
|
||||||
|
|
|
@ -2,5 +2,5 @@
|
||||||
|
|
||||||
if [[ -z "${TEST}" && "${TEST}" = "True" ]]
|
if [[ -z "${TEST}" && "${TEST}" = "True" ]]
|
||||||
then echo " ---> Starting test env"
|
then echo " ---> Starting test env"
|
||||||
else python3 manage.py check_db; gunicorn -c config/gunicorn_conf.py newsblur_web.wsgi:application
|
else python3 manage.py check_db; gunicorn -c config/gunicorn_conf.py --reload newsblur_web.wsgi:application
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Reference in a new issue