diff options
| author | 2026-05-02 20:28:02 +0700 | |
|---|---|---|
| committer | 2026-05-02 20:28:02 +0700 | |
| commit | 507bcbac6b1bf9f1a731afbe82bec10700f4028c (patch) | |
| tree | 8ccb5aed1ebe5a19d8c2f082967fcdf9184f4f2e | |
| parent | 179cf888d20537a5f6e581256be95ad1e2f92d6b (diff) | |
| download | web-507bcbac6b1bf9f1a731afbe82bec10700f4028c.tar.gz web-507bcbac6b1bf9f1a731afbe82bec10700f4028c.zip | |
feat: integrate unix sockets into stage & prod
| -rw-r--r-- | config/config.prod.yaml | 5 | ||||
| -rw-r--r-- | config/config.stage.yaml | 5 | ||||
| -rw-r--r-- | deploy/inventory.yml | 2 | ||||
| -rw-r--r-- | deploy/playbook.yml | 23 | ||||
| -rw-r--r-- | internal/router/router.go | 7 |
5 files changed, 29 insertions, 13 deletions
diff --git a/config/config.prod.yaml b/config/config.prod.yaml index 0b45e1a..2daa3ff 100644 --- a/config/config.prod.yaml +++ b/config/config.prod.yaml @@ -1,8 +1,9 @@ logLevel: info endpoint: - type: http + type: unix config: - listenOn: ":3000" + path: "/etc/sayauz/prod.socket" + chmod: '0666' blogPages: storage: type: b2 diff --git a/config/config.stage.yaml b/config/config.stage.yaml index 23b76aa..151bb4a 100644 --- a/config/config.stage.yaml +++ b/config/config.stage.yaml @@ -1,8 +1,9 @@ logLevel: debug endpoint: - type: http + type: unix config: - listenOn: ":3000" + path: "/etc/sayauz/stage.socket" + chmod: '0666' blogPages: storage: type: b2 diff --git a/deploy/inventory.yml b/deploy/inventory.yml index d3acab8..6b8a384 100644 --- a/deploy/inventory.yml +++ b/deploy/inventory.yml @@ -8,6 +8,7 @@ all: saya_today_web_hostname: sayauz-prod saya_today_web_ipv4_address: 172.16.0.17 saya_today_web_listen_address: saya.uz + saya_today_web_unix_sockets_mount: '/etc/sayauz' stage: hosts: @@ -17,3 +18,4 @@ all: saya_today_web_hostname: sayauz-stage saya_today_web_ipv4_address: 172.16.0.18 saya_today_web_listen_address: stage.saya.uz + saya_today_web_unix_sockets_mount: '/etc/sayauz' diff --git a/deploy/playbook.yml b/deploy/playbook.yml index 8fb9088..9719ed9 100644 --- a/deploy/playbook.yml +++ b/deploy/playbook.yml @@ -2,9 +2,27 @@ - name: Deploy saya-today-web Docker Container hosts: all remote_user: svc_github + + vars: + docker_volumes: + - "{{ saya_today_web_name }}-volume:/data:rw" tasks: - - name: Create a volume + - name: Initialize Unix socket volume + when: >- + saya_today_web_unix_sockets_path is defined and + saya_today_web_unix_sockets_path is string and + saya_today_web_unix_sockets_path | length > 0 + block: + - name: Ensure Unix socket volume exists + community.docker.docker_volume: + name: "sayana_sockets" + - name: Include Unix socket volume in docker volumes list + ansible.builtin.set_fact: + docker_volumes: >- + {{ docker_volumes + ["sayana_sockets:" ~ saya_today_web_unix_sockets_path ~ ":rw"] }} + + - name: Create a data volume community.docker.docker_volume: name: "{{ saya_today_web_name }}-volume" @@ -29,8 +47,7 @@ networks: - name: caddy ipv4_address: "{{ saya_today_web_ipv4_address }}" - volumes: - - "{{ saya_today_web_name }}-volume:/data:rw" + volumes: "{{ docker_volumes }}" restart_policy: unless-stopped no_log: true ... diff --git a/internal/router/router.go b/internal/router/router.go index 2b45761..14973ad 100644 --- a/internal/router/router.go +++ b/internal/router/router.go @@ -433,12 +433,7 @@ func (r *Router) Close() (err error) { } slog.Debug("closing page cache") r.supplements.PageCache.Close() - if r.endpoint.Type == "unix" { - slog.Debug("closing unix socket") - if err = os.Remove(r.endpoint.Config.(*config.UnixConfig).Path); err != nil { - allErrors = append(allErrors, fmt.Errorf("fail to close unix socket: %w", err)) - } - } + return errors.Join(allErrors...) } |