Skip to content

Commit

Permalink
[ansible] allow to specify multiple cs_flags services
Browse files Browse the repository at this point in the history
  • Loading branch information
avkhozov committed Aug 22, 2023
1 parent 22be3c4 commit 975bf2a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion ansible/cs-start.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
restart_policy: unless-stopped
detach: yes
published_ports:
- "{{ private_ip }}:{{ cs_hypnotoad_flags_listen.split(':') | last }}:{{ cs_hypnotoad_flags_listen.split(':') | last }}"
- "{{ private_ip }}:{{ cs_hypnotoad_flags_port }}:{{ cs_hypnotoad_flags_port }}"
env:
POSTGRES_URI: "postgresql://{{ pg_cs_user }}:{{ pg_cs_pass }}@{{ pg_cs_host }}/{{ pg_cs_db }}"

Expand Down
4 changes: 3 additions & 1 deletion ansible/group_vars/all
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ cs_worker_checkers_queues: -q checker
cs_worker_instance: 1

cs_hypnotoad_listen: 127.0.0.1:8080
cs_hypnotoad_flags_listen: 127.0.0.1:8080
cs_hypnotoad_flags_listen:
- 127.0.0.1:8080
cs_hypnotoad_flags_port: 8080
cs_nginx_workers: 1
cs_nginx_upstream_keepalive: 32
cs_nginx_listen: 80
Expand Down
14 changes: 8 additions & 6 deletions ansible/roles/web/templates/cs.nginx.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,18 @@ proxy_cache_path /var/cache/nginx/cs keys_zone=cs:10m max_size=512m inactive=300
log_format cs '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" '
'$request_time $upstream_response_time $pipe';
'$request_time "$upstream_addr" $upstream_response_time';

upstream cs {
server {{cs_hypnotoad_listen}};
keepalive {{cs_nginx_upstream_keepalive}};
server {{ cs_hypnotoad_listen }};
keepalive {{ cs_nginx_upstream_keepalive }};
}

upstream cs_flags {
server {{cs_hypnotoad_flags_listen}};
keepalive {{cs_nginx_upstream_keepalive}};
{% for server in cs_hypnotoad_flags_listen -%}
server {{ server }};
{% endfor -%}
keepalive {{ cs_nginx_upstream_keepalive }};
}

map $http_upgrade $connection_upgrade {
Expand All @@ -26,7 +28,7 @@ map $request_uri $do_not_cache {
}

server {
listen {{cs_nginx_listen}};
listen {{ cs_nginx_listen }};

{% if 'https' == cs_base_url|urlsplit('scheme') -%}
listen 443 ssl;
Expand Down

0 comments on commit 975bf2a

Please sign in to comment.