2. 前端、後台與 API 服務佈署設定 - lyonwang/TechNotes GitHub Wiki
共通安裝
- 透過伺服器管理員新增角色與功能:
-
下載與安裝 .net framework 4.7.2
-
下載完整安裝 Microsoft Web Deploy 3.6
-
開啟 WebDeploy 服務
前端佈署說明
設定 IIS 與 檔案目錄
- 建立目錄 C:\APP\Frontend-Web
- 新增本機帳號 DeployUser 賦予本機管理員權限(請將密碼交付 Developer,以便設定於佈署檔中)
- 開啟 IIS 管理員,新增網站如下圖
- 站台啟用 WebDeploy 發行
- 設定 WebDeply 權限
後台佈署說明
請確認build agent是否有安裝SDK,若無請安裝以下
- 下載與安裝 .NET Core SDK 2.1.202
請確認欲佈置機器是否有安裝WindowsHosting,若無請安裝以下
請確認IIS 模組是否有如預期被更新如下圖所示
設定IIS 應用程式集區如下圖所示
站台名稱 | 站台目錄 | 埠號(port) |
---|---|---|
Backend-Web | C:\APP\Backend-Web | 5000 |
API 服務佈署說明
- 同前端佈署說明,完成以下服務站台設定:
服務名稱 | 站台名稱 | 站台目錄 | 埠號(port) |
---|---|---|---|
Member | ServiceMember | C:\APP\ServiceMember | 54871 |
Billing | ServiceBilling | C:\APP\ServiceBilling | 54872 |
Brand | ServiceBrand | C:\APP\ServiceBrand | 54880 |
ServiceMail | C:\APP\ServiceMail | 54879 | |
SMS | ServiceSMS | C:\APP\ServiceSMS | 54878 |
Payment | ServicePayment | C:\APP\ServicePayment | 54876 |
AG Internal | GameAG | C:\APP\GameAG | 44570 |
AG External | GameAGExternal | C:\APP\GameAGExternal | 44571 |
前後台與各服務 Log 檔傳送至 ELK Log Center 設定說明
安裝 Filebeat
Install on Windows
Download and install the public signing key
-
解壓至 C:\Program Files\filebeat
-
修改 filebeat.yml 如下:
API 服務
注意需要替換 host 欄位值為 hostname
filebeat.prospectors:
- type: log
enabled: true
paths:
- C:\logs\application\MemberService\*.log
fields:
service: MemberService
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\ServiceMember\W3SVC*\*.log
fields:
service: servicemember-web
host: WorkJob01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\logs\application\BillingService\*.log
fields:
service: BillingService
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\ServiceBilling\W3SVC*\*.log
fields:
service: servicebilling-web
host: WorkJob01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\logs\application\BrandService\*.log
fields:
service: BrandService
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\ServiceBrand\W3SVC*\*.log
fields:
service: servicebrand-web
host: WorkJob01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\logs\application\MailService\*.log
fields:
service: MailService
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\ServiceMail\W3SVC*\*.log
fields:
service: servicemail-web
host: WorkJob01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\logs\application\SMSService\*.log
fields:
service: SMSService
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\ServiceSMS\W3SVC*\*.log
fields:
service: servicesms-web
host: WorkJob01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\logs\application\PaymentService\*.log
fields:
service: PaymentService
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\Payment\W3SVC*\*.log
fields:
service: payment-web
host: WorkJob01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\logs\application\ServiceGameAG\*.log
fields:
service: ServiceGameAG
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\Game\AGService\W3SVC*\*.log
fields:
service: servicegameag-web
host: WorkJob01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\logs\application\ServiceGameAGExternal\*.log
fields:
service: ServiceGameAGExternal
host: WorkJob01
category: application
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\Game\AGServiceExternal\W3SVC*\*.log
fields:
service: servicegameagexternal-web
host: WorkJob01
category: iis
fields_under_root: true
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: true
setup.template.settings:
index.number_of_shards: 3
output.logstash:
hosts: ["192.168.20.54:5044"]
前後台 IIS Log
注意需要替換 host 欄位值為 hostname
filebeat.prospectors:
- type: log
enabled: true
paths:
- C:\IISLog\Frontend-Web\W3SVC*\*.log
fields:
service: frontend-web
host: Websites01
category: iis
fields_under_root: true
- type: log
enabled: true
paths:
- C:\IISLog\Backend-Web\W3SVC*\*.log
fields:
service: backend-web
host: Websites01
category: iis
fields_under_root: true
filebeat.config.modules:
path: ${path.config}/modules.d/*.yml
reload.enabled: true
setup.template.settings:
index.number_of_shards: 3
output.logstash:
hosts: ["192.168.20.54:5044"]
- install Windows service
以 Administrator 執行 Powershell,在 C:\Program Files\filebeat 目錄執行以下命令:
C:\Program Files\filebeat> install-service-filebeat.ps1
- 安裝完成後,再手動啟動服務 filebeat
IIS Log 設定
- IIS Log 目錄與欄位設定
- IIS Log 目錄
主機 | 站台 | 目錄 |
---|---|---|
Website | Frontend-Web | C:\IISLog\Frontend-Web |
Website | Backend-Web | C:\IISLog\Backend-Web |
WorkJob | ServiceMember | C:\IISLog\ServiceMember |
WorkJob | ServiceBilling | C:\IISLog\ServiceBilling |
WorkJob | ServiceBrand | C:\IISLog\ServiceBrand |
WorkJob | ServiceMail | C:\IISLog\ServiceMail |
WorkJob | ServiceSMS | C:\IISLog\ServiceSMS |
WorkJob | Payment | C:\IISLog\Payment |
WorkJob | GameAG | C:\IISLog\Game\AGService |
WorkJob | GameAGExternal | C:\IISLog\Game\AGServiceExternal |