# https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions
name: XCrawler - Build & Tests
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#jobsjob_idruns-on
on:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
pull_request:
branches: [ develop ]
types: [ opened, synchronize ]
jobs:
sonar_cloud:
name: SonarCloud
uses: ./.github/workflows/sonar_cloud.yml
secrets: inherit
security_check:
name: Security check
uses: ./.github/workflows/security_check.yml
secrets: inherit
code_standards:
name: Code standards check
needs: [ sonar_cloud, security_check ]
strategy:
matrix:
lint: [ phpstan, phpmd, phpcs ]
uses: ./.github/workflows/code_standards.yml
with:
lint: ${{ matrix.lint }}
secrets: inherit
tests:
name: Execute UnitTest
needs: [ code_standards ]
strategy:
matrix:
test: [ Client, JAV, Flickr, Core ]
uses: ./.github/workflows/unittest.yml
with:
test: ${{ matrix.test }}
secrets: inherit
finalizing_build:
name: "All Parallel Tests passed"
needs: [ tests ]
uses: ./.github/workflows/codecov.yml
secrets: inherit
Continue reading Github action – Reusable Category: Linux
HAProxy Health check fails
backend be_staging
option httpchk
server staging 192.168.1.60:80 check
Web server sử dụng Nginx
Đối với config trên thì HAProxy báo be_staging
not available dù rằng mọi access đều working fine. !
Check Nginx log ta có
192.168.1.4 - - [27/Aug/2023:21:36:00 +0700] "OPTIONS / HTTP/1.0" 405 166 "-" "-"
Vậy là do Nginx nó trả về 405 cho OPTIONS requests.
Update HAProxy
backend be_staging
option httpchk GET /
http-check expect status 200
server staging 192.168.1.60:80 check
Và mọi thứ trở về lại bình thường !
Laravel – Stable Diffusion
Sau một thời gian nghịch Stable Diffusion thì giờ cũng chút hứng thú với … code Laravel cho em nó.
https://github.com/jooservices/Stable-Diffusion
Về cơ bản
- Tạo ra queues để liên tục generate images
- Tạo ra các “base prompt” để có thể tái` sử dụng ( ví dụ có thể tạo `
`$prompt->portraits('Irene Aronson')
thì sẽ tự add prompt là portraits của nghệ sĩ Irene Aronson
Alrite. Tuy nhiên trước đó thì cần chuẩn bị 1 số thứ
- Stable Diffusion ( webUI ) chạy service
Description=systemd service start stable-diffusion
[Service]
Type=simple
Restart=always
RestartSec=1
ExecStart=/bin/bash /home/joos/stable-diffusion-webui/webui.sh
User=joos
WorkingDirectory=/home/joos/stable-diffusion-webui/
StandardOutput=append:/var/log/sdwebui.log
StandardError=append:/var/log/sdwebui.log
[Install]
WantedBy=multi-user.target
- 1 em cron để chạy schedule:run của Laravel
Xong ! Giờ thì ta có 2 cách
- Generate ra “queues” qua command
php artisan stable-diffusion:generate --prompt="a beautiful girl at 20 years old. she has colorful hair"
Command này sẽ sinh ra 1.001 queues ứng với prompt trên và … toàn bộ models mình đang có.
- Code thêm theo ý
$response = $service
->txt2img()
->generate($payload)
->save($queue->uuid)
->getResponse();
Ubuntu – Create system user without login
sudo groupadd --system prometheus
sudo useradd -s /sbin/nologin --system -g prometheus prometheus
Sending test AlertManager
/opt/alertmanager/amtool --alertmanager.url=http://localhost:9093/ alert add alertname="test123" severity="test-telegram" job="test-alert" instance="localhost" exporter="none" cluster="test"
Gateway server
Hiện tại gateway server chính thức trở thành server KHÔNG THỂ THIẾU trong Network của mình
Thật ra mà nói em nó đóng nhiều vai trò hơn là Gateway thuần túy.
IP em nó là 192.168.1.4
Continue reading Gateway serverStable Diffusion – Public port
Bài viết này mình không tập trung vào Stable Diffusion mà là cách xử lý bài toán public port khi bản thân nó chỉ bind cho localhost.
By default Stable Diffusion chỉ listening trên 127.0.0.1:7860, nghĩa là bạn không thể public ra ngoài Internet hoặc access từ các máy khác trong LAN.
Tất nhiên ta vẫn có thể sử dụng paramter –listen để listening trên 0.0.0.0:7860. Tuy nhiên cái giá phải trả là sẽ bị hạn chế nhiều thứ ( góc nhìn của developer AUTOMATIC1111 có lẽ là hạn chế bị change settings, cài extensions ngoài ý muốn khi public ).
Nhưng nếu bạn vẫn muốn làm điều này thì sao ? Giải quyết bài toán này khá đơn giản với HAProxy
- HAProxy có thể dùng Frontend để listening 1 port nhất định sau đó forwarding về 1 IP khác. Trong trường hợp này là 127.0.0.1
Vậy trên chính cái máy bạn install Stable Diffusion WebUI, ta setup thêm HAProxy và cấu hình
frontend http
bind :8080
mode http
default_backend be_develop
backend be_develop
# default backend
#option httpchk
server hosting 127.0.0.1:7860
Nghĩa là ta listening port 8080 từ ngoài vào ( tất nhiên router đã NAT 8080 về IP máy rồi ).
Sau đó do HAProxy nằm trên chính máy Stable Diffusion nên hiển nhiên access 127.0.0.1 được. Vậy ta cứ forward về đó thôi.
Xong 😀
Tất nhiên lúc này ta có thể secure thêm 1 chút bằng basic authenticate.

Access localhost inside docker container
Use host
172.17.0.1
And of course, make sure your local service allowed remote connection.
HAProxy SSL Passthrough
frontend ssl
bind :443
mode tcp
option tcplog
# Wait for a client hello for at most 5 seconds
tcp-request inspect-delay 5s
tcp-request content accept if { req_ssl_hello_type 1 }
use_backend be_ssl_hosting if { req_ssl_sni -i jooservices.com }
default_backend be_ssl
backend be_ssl_hosting
mode tcp
balance roundrobin
server aaa_ssl_server 192.168.1.39:443 check
My infrastructure network
Về cơ bản infrastructure network này mình build chưa được hoàn thiện, nhưng cũng thấy tương đối happy về nó. 1 chút chia sẽ.
Router 3910
- Mình có tổng cộng 4 WANs. Tuy nhiên thực tế chỉ có 1 WAN chính với IP tĩnh
Core Switch – CnMatrix 2028-P
- Thật ra em này có 1 điểm dở là không có port 2.5Gbe nên vướng 1 con Asus AX86U đành phải xài tạm port 1Gbe
- 1 port SFP+ đến “Workstation”
- 1 port 1Gbe đến X300
- 1 port 1Gbe đến ProDesk
- 1 port 1Gbe đến Asus AX86U

ProDesk
- Em nó tuy nhỏ bé nhưng lại gần như là mấu chốt chính của toàn bộ Network. Gọi em nó là
gatekeeper
- HAProxy
- Tiếp nhận 100% mọi requests và sau đó forwarding đến các server phía sau
- Cũng là em SSH Jumper luôn
- Tuy nhiên 1 số bất cập mình chưa làm được
- Forward RDP
- Passthrough SSL ( cái này đúng ra đã từng làm được mà giờ lại bị stucked )
- Grafana
- Loki
- Syslog
- Pihole
Asrock X300
- Bản chất em này … ăn điện ít mà specs cũng kha khá ( 5700G / 64GB RAM & 2 TB SSD ) nên “hiểu” em nó như 1 thiết bị thứ sẽ online gần như 24/7. Do đó các “services” hosting trên đây là các services cần online liên tục
- 1 con Virtualmin để hosting … chính các web này và n web khác
- và 1 vài VM khác
Workstation
- Em nó chính thức đã được triển khai với ESXi 7
- 1 em VM “SMB” được attach với các HDDs. Em này bản thân cũng khá nhỏ, chủ yếu để phục vụ SMB / Plex & Torrent thôi
- Em Workstation ngốn điện cao nên lý thuyết cũng khó online 24/7 mà sẽ có lúc down. Tuy nhiên specs em nó mạnh. Nên các service cần resource cao sẽ nằm trên đây.