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:
|
||||
- static
|
||||
|
||||
- name: Reload gunicorn due to no git upstream changes
|
||||
become: yes
|
||||
block:
|
||||
- name: Find gunicorn process
|
||||
shell: "ps -C gunicorn fch -o pid | head -n 1"
|
||||
register: psaux
|
||||
- name: Reload gunicorn
|
||||
command: "kill -HUP {{ psaux.stdout }}"
|
||||
# Only restart if there were no changes to the git repo or the static tag was applied
|
||||
when: not pulled.changed or "'static' in ansible_playbook_tag"
|
||||
rescue:
|
||||
- name: Restart Docker Container
|
||||
command: "docker restart newsblur_web"
|
||||
tags:
|
||||
- static
|
||||
- name: Run new Docker container with temporary name
|
||||
docker_container:
|
||||
name: "newsblur_web_new"
|
||||
image: "newsblur/newsblur_web:latest"
|
||||
pull: true
|
||||
state: started
|
||||
restart_policy: always
|
||||
command: "gunicorn newsblur.wsgi:application --bind :8000 --workers 4"
|
||||
hostname: "newsblur_web_new"
|
||||
networks:
|
||||
- name: newsblur-network
|
||||
ports:
|
||||
- "8001:8000" # Use different port for new instance
|
||||
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 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
|
||||
become: yes
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
- /etc/hosts:/etc/hosts
|
||||
with_items:
|
||||
- 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' }}"
|
||||
- container_name: "task-celery"
|
||||
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_fields = 1000
|
||||
worker_tmp_dir = "/dev/shm"
|
||||
reload = True
|
||||
|
||||
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
|
||||
{% for host in groups.staging %}
|
||||
server {{host}} {{host}}.node.nyc1.consul:8000
|
||||
server {{host}} {{host}}.node.nyc1.consul:8001 backup
|
||||
{% endfor %}
|
||||
|
||||
backend blog
|
||||
|
|
|
@ -113,16 +113,19 @@ backend app_django_counts
|
|||
balance roundrobin
|
||||
option httpchk GET /_haproxychk
|
||||
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
|
||||
balance roundrobin
|
||||
option httpchk GET /_haproxychk
|
||||
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
|
||||
balance roundrobin
|
||||
option httpchk GET /_haproxychk
|
||||
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
|
||||
option httpchk HEAD /maintenance
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
|
||||
if [[ -z "${TEST}" && "${TEST}" = "True" ]]
|
||||
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
|
||||
|
|
Loading…
Add table
Reference in a new issue