FiveM Recipe คืออะไร? txAdmin Recipe ใช้สร้าง Server อย่างไร
FiveM Recipe คือไฟล์คำสั่งสำหรับระบบ Recipe Deployer ของ txAdmin ที่บอก txAdmin ว่าต้องทำอะไรบ้างเพื่อสร้าง FiveM Server ให้พร้อมใช้งาน ตั้งแต่ดาวน์โหลด Resources, สร้าง Folder, ดาวน์โหลด server.cfg, ใส่ Server Key, ตั้งค่า Database ไปจนถึงจัดวางไฟล์ต่าง ๆ
Recipe จึงเปรียบเหมือน สูตรติดตั้ง Server อัตโนมัติ
แทนที่ Admin จะทำเองทีละขั้น
ดาวน์โหลด Resources
↓
สร้าง Folder
↓
Copy Files
↓
สร้าง server.cfg
↓
ใส่ Database
↓
ตั้ง Server Key
↓
เปิด Resources
Recipe สามารถสั่งให้ txAdmin ทำขั้นตอนเหล่านี้ตามลำดับได้
ไฟล์ Recipe ของ txAdmin ใช้รูปแบบ YAML และสามารถนำเข้าได้ทั้งจาก Popular Recipes ที่แสดงใน txAdmin หรือจาก URL ของ Recipe ที่รองรับ
① FiveM Recipe คืออะไร
Recipe คือเอกสาร YAML ที่อธิบายขั้นตอนการ Deploy FiveM Server
ตัวอย่างโครงสร้างแบบย่อ
name: My Server
version: 1.0
author: Admin
tasks:
- action: download_file
url: FILE_URL
path: ./file.zip
txAdmin จะอ่าน Recipe จากบนลงล่างแล้ว Execute แต่ละ Task ตามลำดับ
② Recipe ใช้ทำอะไร
Recipe สามารถช่วยสร้าง Server โดยอัตโนมัติ เช่น
ดาวน์โหลด Resources
ดาวน์โหลด GitHub Repository
สร้าง Folder
แตก ZIP
Copy Files
Move Files
ลบไฟล์ชั่วคราว
สร้าง
server.cfgReplace ค่าในไฟล์
เชื่อม Database
Run SQL
กำหนด Variables
จึงลดงาน Manual ในการติดตั้ง Server ได้มาก
③ Recipe อยู่ตรงไหนใน txAdmin
ตอนสร้าง Server ผ่าน txAdmin จะมีขั้นตอนเลือก
Deployment Type
↓
Popular Recipes
จากนั้นเลือก Template เช่น
FiveM Basic Server (CFX Default)
แล้วเข้าสู่
Recipe Deployer
เพื่อ Review และ Run Recipe
④ Popular Recipes คืออะไร
Popular Recipes คือรายการ Server Templates ที่ txAdmin แสดงไว้ให้เลือกจากหน้า Setup
รายการปัจจุบันมีตัวอย่าง เช่น
FiveM Basic Server
ESX Legacy
Qbox
QBCore Framework
รวมถึง Recipe สำหรับระบบอื่นที่ Repository ของ Cfx.re กำหนดไว้ในช่วงนั้น
รายชื่อสามารถเปลี่ยนได้ในอนาคต
⑤ มือใหม่ควรเลือก Recipe ไหน
ถ้าเพิ่งเริ่มสร้าง Server และต้องการเรียนรู้พื้นฐาน แนะนำให้เริ่มจาก
FiveM Basic Server (CFX Default)
เพราะเป็น Minimal Server
เหมาะสำหรับทดสอบว่า
FXServer เปิดได้
txAdmin ทำงาน
Server Key ถูก
Player เข้าได้
Resources พื้นฐานทำงาน
ก่อนเพิ่ม Framework ขนาดใหญ่
⑥ CFX Default Recipe คืออะไร
CFX Default คือ Recipe พื้นฐานของ FiveM
เป้าหมายคือสร้าง Minimal Server ที่มี Configuration และ Resources ขั้นพื้นฐานเพียงพอสำหรับเปิด FiveM Server
ไม่ใช่ RP Server สำเร็จรูปขนาดใหญ่
เหมาะมากสำหรับใช้เป็น Foundation
⑦ Recipe ต่างจาก Server Pack อย่างไร
สองอย่างนี้ไม่เหมือนกัน
Recipe
คำสั่งติดตั้ง
↓
ดาวน์โหลดสิ่งที่ต้องใช้
↓
สร้าง Server
Server Pack
ไฟล์ Server ที่มีคนจัดเตรียมไว้แล้ว
↓
นำมา Extract/Copy
↓
เปิดใช้งาน
Recipe จึงเน้นการ สร้าง Environment ตามขั้นตอน
ขณะที่ Server Pack มักเป็น Snapshot ของ Server ที่มีไฟล์รวมมาแล้ว
⑧ Recipe ดีกว่า Server Pack ไหม
ในแง่ความโปร่งใส Recipe มีข้อดีคือสามารถ Review ได้ว่า
ดาวน์โหลดอะไร
สร้างอะไร
แก้ไฟล์อะไร
Run SQL อะไร
ก่อน Deploy
แต่ไม่ได้หมายความว่า Recipe ทุกตัวปลอดภัย
Recipe จาก Source ภายนอกยังต้องตรวจ Code และ Source เหมือน Script อื่น
⑨ Recipe ใช้ภาษาอะไร
Recipe ใช้รูปแบบ
YAML
ไฟล์จึงมักมีชื่อ เช่น
recipe.yaml
YAML ใช้ Indentation เป็นส่วนหนึ่งของ Structure
ดังนั้น Space ผิดสามารถทำให้ Recipe Parse ไม่สำเร็จได้
⑩ ตัวอย่าง Metadata ของ Recipe
Recipe สามารถมีข้อมูล เช่น
name: MyFiveM
version: 1.0.0
author: MyTeam
description: FiveM server recipe
ข้อมูลเหล่านี้ช่วยบอกว่า Recipe คืออะไร ใครสร้าง และเป็น Version ใด
⑪ name คืออะไร
name คือชื่อ Recipe
ตัวอย่าง
name: FiveM Basic Server
ควรเป็นชื่อสั้นและสื่อว่ากำลัง Deploy Server ประเภทใด
⑫ version คืออะไร
version ใช้ระบุ Version ของ Recipe
ตัวอย่าง
version: 2.0.0
ช่วยให้ผู้ดูแลรู้ว่ากำลังใช้ Recipe รุ่นไหน
โดยเฉพาะ Framework ที่อัปเดต Recipe เป็นระยะ
⑬ author คืออะไร
author ระบุผู้จัดทำ Recipe
ตัวอย่าง
author: MyTeam
หากใช้ Recipe จากบุคคลภายนอกควรตรวจว่า Source และ Author เชื่อถือได้หรือไม่
ไม่ควร Deploy Recipe จาก URL ไม่รู้จักลง Production โดยไม่ Review
⑭ description คืออะไร
ใช้บอกว่า Recipe ทำอะไร
เช่น
description: Minimal FiveM server recipe
ช่วยให้ผู้ใช้แยก Recipe ที่มีชื่อคล้ายกันได้ง่ายขึ้น
⑮ tasks คืออะไร
หัวใจสำคัญของ Recipe คือ
tasks:
ภายในจะเป็นรายการ Action ที่ txAdmin ต้องทำ
ตัวอย่าง
tasks:
- action: ensure_dir
path: ./resources
หมายถึงสร้าง Directory ตามที่กำหนด
⑯ Task ทำงานตามลำดับหรือไม่
ใช่
txAdmin Recipe จะ Execute Actions ตามลำดับ
แนวคิดคือ
Task 1
↓
Task 2
↓
Task 3
↓
Task 4
หาก Task หนึ่งเกิด Failure กระบวนการ Deployment สามารถหยุดได้
นี่ช่วยป้องกันไม่ให้ Recipe เดินหน้าต่อทั้งที่ขั้นตอนสำคัญก่อนหน้าล้มเหลว
⑰ download_github คืออะไร
เป็น Recipe Action สำหรับดาวน์โหลด Repository จาก GitHub
ตัวอย่าง Concept
- action: download_github
src: owner/repository
dest: ./resources/example
เหมาะสำหรับ Framework หรือ Resource ที่เผยแพร่ผ่าน GitHub
⑱ download_file คืออะไร
ใช้ดาวน์โหลดไฟล์จาก URL
ตัวอย่าง
- action: download_file
url: FILE_URL
path: ./tmp/file.zip
มักใช้กับ
ZIP
Configuration
Resource Package
server.cfg
ตามที่ Recipe ต้องการ
⑲ unzip ใช้ทำอะไร
หลัง Download ZIP แล้ว Recipe สามารถสั่งแตกไฟล์ได้
แนวคิด
download_file
↓
unzip
↓
move_path
↓
remove_path
ทำให้กระบวนการติดตั้งเป็นอัตโนมัติ
⑳ ensure_dir คืออะไร
ensure_dir ใช้สร้าง Directory หากยังไม่มี
เช่น
- action: ensure_dir
path: ./resources
ช่วยเตรียมโครงสร้าง Folder ก่อน Copy Resources ลงไป
㉑ move_path คืออะไร
ใช้ย้าย File หรือ Directory จากตำแหน่งหนึ่งไปอีกตำแหน่ง
เช่น
Temporary Folder
↓
Resource Folder
CFX Default Recipe ปัจจุบันก็ใช้ Action ลักษณะนี้ในการจัด Resources บางส่วน
㉒ copy_path คืออะไร
ใช้ Copy Path โดยยังเก็บ Source เดิมไว้
ต่างจาก move_path ที่มีแนวคิดเป็นการย้ายตำแหน่ง
ใช้ได้เมื่อ Recipe ต้องการ File เดียวกันมากกว่าหนึ่งตำแหน่ง
㉓ remove_path คืออะไร
ใช้ลบ File หรือ Folder ที่ Recipe ไม่ต้องการแล้ว
ตัวอย่างหลัง Download และ Extract
tmp
↓
ใช้งานเสร็จ
↓
remove_path
ช่วยไม่ให้ Temporary Files ค้างอยู่ใน Server Data
㉔ write_file คืออะไร
ใช้สร้างหรือเขียนไฟล์จาก Recipe
สามารถนำไปใช้สร้าง
Config
Script File
Text File
ตาม Template ที่ผู้พัฒนา Recipe ออกแบบไว้
นี่คือเหตุผลที่ต้อง Review Recipe ก่อน Run
㉕ replace_string คืออะไร
ใช้แทนข้อความในไฟล์
เช่น Recipe มี Template
sv_licenseKey "{{svLicense}}"
ระบบสามารถแทน
{{svLicense}}
ด้วย Server Registration Key ที่ผู้ใช้กรอกใน Recipe Deployer
㉖ Recipe ใส่ Server Key ให้อัตโนมัติได้ไหม
ได้
txAdmin มี Context Variable
svLicense
และ Recipe สามารถใช้
{{svLicense}}
ใน server.cfg
เมื่อผู้ใช้กรอก Server Key แล้ว Deployer จะ Replace ค่าให้ตามระบบ
จึงไม่ต้องเปิด server.cfg แล้ว Copy Key ด้วยมือทุก Recipe
㉗ serverEndpoints คืออะไร
Recipe Deployer มี Context Variable สำหรับ Server Endpoint
เช่น
serverEndpoints
Default Game Endpoint สามารถถูกสร้างในรูปแบบ
0.0.0.0:30120
ตาม Configuration ของ Server
จึงสามารถสร้าง endpoint_add_tcp และ endpoint_add_udp ให้เหมาะกับ Environment ได้
㉘ maxClients ใช้ใน Recipe ได้ไหม
ได้
Recipe Deployer มี Variable
maxClients
สำหรับจำนวน Player สูงสุด
จากนั้น server.cfg สามารถใช้ค่าในลักษณะ
sv_maxclients {{maxClients}}
ได้
㉙ Recipe ตั้ง OneSync ได้ไหม
Recipe Metadata รองรับค่า
$onesync
เช่น
$onesync: on
เพื่อระบุ Requirement เกี่ยวกับ OneSync สำหรับ Deployment
CFX Default FiveM Recipe ปัจจุบันก็ระบุ OneSync ไว้ใน Recipe
㉚ Recipe กำหนด Minimum FXServer ได้ไหม
ได้
มี Metadata
$minFxVersion
ใช้กำหนด Minimum FXServer Version ที่ Recipe ต้องการ
มีประโยชน์เมื่อ Framework หรือ Resource ต้องการ Server Artifact รุ่นใหม่กว่าระดับหนึ่ง
㉛ Recipe เชื่อม Database ได้ไหม
ได้
Recipe System รองรับ Actions เช่น
connect_database
query_database
และ Context Variables เกี่ยวกับ Database เช่น
dbHost
dbPort
dbUsername
dbPassword
dbName
dbConnectionString
จึงสามารถใช้ Deploy Framework ที่ต้องมี Database ได้
㉜ ทำไม ESX/QBCore Recipe ต้องถาม Database
Framework RP จำนวนมากต้องเก็บข้อมูล เช่น
Character
Money
Jobs
Vehicles
Inventory
Recipe จึงอาจต้องรู้ Database Connection เพื่อ
สร้าง Database
↓
Import SQL
↓
สร้าง Connection String
↓
เขียน Config
ต่างจาก CFX Basic Server ที่สามารถเริ่มได้โดยไม่ต้องมี RP Database
㉝ QBCore มี Recipe หรือไม่
รายการ Popular Recipes ปัจจุบันของ Repository ทางการมี Recipe สำหรับ QBCore Framework
ดังนั้นสามารถใช้ txAdmin Recipe Deployer เพื่อสร้าง QBCore Environment ได้
แต่ต้องตรวจ Documentation และ Requirement ปัจจุบันของ Framework ก่อน Deploy
㉞ ESX มี Recipe หรือไม่
มี ESX Legacy อยู่ใน Popular Recipes ปัจจุบันเช่นกัน
Recipe สามารถช่วยเตรียม
Framework
Resources
Database
Config
ได้หลายส่วน
แต่หลัง Deploy แล้ว Admin ยังควรเรียนรู้โครงสร้าง ESX ด้วย ไม่ควรพึ่ง Recipe อย่างเดียว
㉟ Qbox มี Recipe หรือไม่
รายการ Recipe ปัจจุบันยังมี Qbox สำหรับ FiveM Roleplay
เหมาะกับผู้ที่ต้องการเริ่ม Framework ผ่าน txAdmin Deployer
แต่ควรตรวจ Source และ Documentation ล่าสุดก่อนใช้งานจริงเสมอ
㊱ Recipe ต้องใช้ Server Key ไหม
สำหรับการ Deploy FiveM Server จะต้องมี Server Registration Key ที่เหมาะสม
Recipe Deployer มี Variable
svLicense
สำหรับรับค่าดังกล่าว
จึงเป็นหนึ่งใน Input สำคัญตอนสร้าง Server
㊲ Recipe ทำ server.cfg ให้ได้ไหม
ได้
CFX Default Recipe ปัจจุบันดาวน์โหลด server.cfg Template มาเป็นส่วนหนึ่งของ Deployment
ภายในสามารถมีค่าประเภท
sv_hostname
sv_projectName
sv_projectDesc
sv_licenseKey
sv_maxclients
endpoint_add_tcp
endpoint_add_udp
ensure
ตาม Template ที่ Recipe กำหนด
㊳ Recipe ทำ Resources Folder ให้ได้ไหม
ได้
หนึ่งในเงื่อนไขหลัง Deployment คือ txAdmin จะตรวจ Target Folder ว่ามี
server.cfg
และ
resources
อยู่หรือไม่
เพื่อช่วยยืนยันว่าโครงสร้าง Server ขั้นพื้นฐานถูกสร้างสำเร็จ
㊴ Recipe สามารถแก้ admins.json ได้ไหม
Recipe มีระบบจำกัดการทำงานให้อยู่ภายใน Target Deployment Folder
เอกสาร txAdmin ยกตัวอย่างว่า Recipe จะไม่สามารถใช้ write_file ไปเขียน admins.json นอกพื้นที่ที่กำหนดได้
นี่ช่วยจำกัดขอบเขตของ Recipe Deployer
แต่ก็ไม่ได้แปลว่าควรเชื่อ Recipe ทุกตัวโดยไม่อ่าน
㊵ Recipe จาก URL ใช้ได้ไหม
ได้
txAdmin รองรับการ Import Recipe ผ่าน URL
จึงสามารถใช้ Recipe จาก
Framework Official Repository
Developer Repository
Organization Repository
ได้
แต่ควรใช้ Source ที่น่าเชื่อถือ
㊶ Recipe จาก Discord ควรใช้ไหม
ควรระวังมาก
ถ้ามีคนส่ง URL Recipe ผ่าน Discord ให้ตรวจ
Repository Owner
Source Code
Recipe Tasks
Download URLs
SQL
Dependencies
Last Update
Documentation
ก่อน Run
อย่า Deploy Production Server จาก Recipe ที่ไม่รู้ที่มาเพียงเพราะมีคนบอกว่า “พร้อมเปิด”
㊷ Recipe อันตรายได้ไหม
Recipe มีความสามารถจัดการ File, Download Resources และ Run Database Queries ภายในขอบเขตของ Deployer
ดังนั้น Recipe ที่ออกแบบไม่ดีหรือมี Source ที่ไม่น่าเชื่อถือสามารถสร้าง Server Environment ที่มีปัญหาได้
ควรคิดว่า Recipe เป็น
Automation Code
ไม่ใช่แค่ไฟล์ Configuration ธรรมดา
㊸ ต้องอ่าน Recipe ก่อน Run ไหม
ควร
ใน txAdmin มีขั้นตอน
Review Recipe
ก่อน Run
อย่ากด Next อย่างเดียวเมื่อใช้ Recipe จากบุคคลภายนอก
อย่างน้อยตรวจ
URL ที่ Download
GitHub Repository
Database Commands
Resources
server.cfg
Variables
ก่อน
㊹ Recipe ล้มเหลวกลางทางทำอย่างไร
Recipe Tasks ทำงานตามลำดับ และ Failure สามารถหยุด Deployment ได้
ให้ดู Step ที่ Error เช่น
download_file failed
หรือ
database connection failed
จากนั้นแก้ Root Cause
ไม่ควร Run ซ้ำหลายรอบทันทีโดยไม่รู้ว่า Task ก่อนหน้าได้สร้างไฟล์อะไรไว้แล้ว
㊺ Recipe Download GitHub ไม่ได้เกิดจากอะไร
สาเหตุอาจรวมถึง
Internet
GitHub API
Repository เปลี่ยน
Branch/Tag ไม่มีแล้ว
URL ผิด
Rate Limit
Permission
Recipe Documentation ยังเตือนว่าการเรียก GitHub จำนวนมากโดยไม่ระบุ ref สามารถสร้างปัญหากับ GitHub API Limits ได้
㊻ Recipe เก่ามีปัญหาได้ไหม
ได้
Recipe เก่าอาจอ้างถึง
Repository ที่ย้ายแล้ว
Branch ที่ถูกลบ
Resource เก่า
Framework เก่า
SQL Schema เก่า
Artifact Requirement เก่า
จึงควรใช้ Recipe Version ปัจจุบันจาก Source หลักของ Framework
㊼ Recipe Deploy เสร็จแล้วแปลว่า Server พร้อม Production ไหม
ไม่เสมอ
Recipe Deploy สำเร็จหมายความว่าขั้นตอนติดตั้งตาม Recipe สำเร็จ
แต่ Production Server ยังควรตรวจ
Console
Resources
Database
Permissions
Security
Server Key
OneSync
Player Join
Performance
Backup
ก่อนเปิดให้ผู้เล่นจริง
㊽ Checklist ก่อนใช้ FiveM Recipe
ตรวจตามนี้
Recipe มาจาก Source ที่เชื่อถือได้
Author ถูกต้อง
Version ปัจจุบัน
Download URLs ถูกต้อง
Framework ตรงกับที่ต้องการ
Database พร้อม
Server Key พร้อม
Artifact รองรับ
OneSync ตรง Requirement
มี Backup
Review Tasks แล้ว
ไม่ Deploy ทับ Production โดยไม่ทดสอบ
โดยเฉพาะ Recipe ที่ไม่ใช่ CFX Default
㊾ FiveM Recipe เหมาะกับใคร
เหมาะกับ
มือใหม่สร้าง Server
Developer สร้าง Test Environment
Hosting Deploy Server
Framework Maintainer
Server Owner ที่ต้องติดตั้ง Environment ซ้ำ
ทีมที่ต้องการ Standardized Deployment
Recipe ช่วยให้ Server หลายเครื่องสามารถสร้างด้วยกระบวนการใกล้เคียงกัน
ลด Human Error จากการติดตั้งด้วยมือ
㊿ สรุป FiveM Recipe คืออะไร
FiveM Recipe คือไฟล์ YAML ที่บอก txAdmin Recipe Deployer ว่าต้องทำขั้นตอนใดบ้างเพื่อสร้าง FiveM Server
โครงสร้างสามารถครอบคลุมตั้งแต่
Download
↓
Extract
↓
Create Folder
↓
Move/Copy Files
↓
Configure Database
↓
สร้าง server.cfg
↓
ใส่ Server Key
↓
ตั้ง Endpoints
↓
พร้อมเปิด Server
Recipe จึงไม่ได้เป็น FiveM Server เอง แต่เป็น
สูตร + Automation
สำหรับสร้าง Server
มือใหม่ควรเริ่มจาก
FiveM Basic Server (CFX Default)
เพื่อให้ Server ขั้นพื้นฐานทำงานก่อน แล้วจึงค่อยทดลอง Recipe ของ ESX, QBCore, Qbox หรือ Framework อื่น
comsiam แนะนำให้ใช้ Recipe จาก Repository ทางการของ Cfx.re หรือ Framework ที่เชื่อถือได้ และต้อง Review Recipe ก่อน Run ทุกครั้ง โดยเฉพาะ Recipe ที่ดาวน์โหลด Resources หรือแก้ Database
ข้อดีของ Recipe คือทำให้ขั้นตอน Deploy Server ทำซ้ำได้ง่ายและลดงาน Manual แต่ Recipe ไม่ได้แทนความรู้เรื่อง FXServer, server.cfg, Resources, Database, Network และ Security
เมื่อเข้าใจ Recipe แล้ว ผู้ดูแล FiveM Server ของ comsiam จะสามารถเลือกได้ถูกต้องว่าจะใช้ CFX Default, Framework Recipe หรือสร้าง Recipe ของตัวเอง ซึ่งจะต่อยอดโดยตรงไปยังขั้นตอนการสร้าง Server ด้วย txAdmin Recipe ในหัวข้อถัดไป
Comments
Post a Comment