# 🚀 Quick Start Guide

## ✅ โปรเจคพร้อม Deploy แล้ว!

Port ถูกเปลี่ยนจาก **8080** เป็น **9087** เรียบร้อยแล้ว

---

## 📦 วิธีอัปโหลดไปยัง Server

### สำหรับ Windows Server (XAMPP)

1. **คัดลอกไฟล์ทั้งหมด** ไปยัง:
   ```
   C:\xampp\htdocs\advice\_go.lead
   ```

2. **เปิด Command Prompt** ในโฟลเดอร์นั้นแล้วรัน:
   ```cmd
   start-server.bat
   ```

3. **หรือติดตั้งเป็น Windows Service** (แนะนำ):
   ```cmd
   install-service.bat
   ```
   (ต้องรันด้วยสิทธิ์ Administrator และต้องมี [NSSM](https://nssm.cc/download))

---

### สำหรับ Linux Server

1. **อัปโหลดไฟล์** ผ่าน FTP/SCP ไปยัง:
   ```bash
   /var/www/html/advice/_go.lead
   ```

2. **Build Application**:
   ```bash
   cd /var/www/html/advice/_go.lead
   go build -o leadapp main.go
   chmod +x leadapp
   ```

3. **ติดตั้ง Systemd Service**:
   ```bash
   sudo cp go-lead.service /etc/systemd/system/
   sudo systemctl daemon-reload
   sudo systemctl enable go-lead
   sudo systemctl start go-lead
   ```

4. **ตั้งค่า Nginx** (ถ้ายังไม่มี):
   ```bash
   sudo cp nginx-config.conf /etc/nginx/sites-available/advice-go-lead
   sudo ln -s /etc/nginx/sites-available/advice-go-lead /etc/nginx/sites-enabled/
   sudo nginx -t
   sudo systemctl reload nginx
   ```

5. **ตั้งค่า SSL**:
   ```bash
   sudo certbot --nginx -d advice.ezmember.org
   ```

---

## 🔍 ตรวจสอบการทำงาน

### Windows
```cmd
netstat -ano | findstr 9087
```

### Linux
```bash
sudo systemctl status go-lead
netstat -tlnp | grep 9087
curl http://localhost:9087/
```

---

## 🌐 เข้าใช้งาน

- **ทดสอบ Local**: http://localhost:9087
- **URL จริง**: https://advice.ezmember.org/_go.lead

---

## 📚 เอกสารเพิ่มเติม

อ่านรายละเอียดเพิ่มเติมได้ที่ `DEPLOY.md`

---

## ⚠️ สิ่งที่ต้องตรวจสอบ

- ✅ Port 9087 ว่าง (ไม่มีโปรแกรมอื่นใช้)
- ✅ Firewall เปิด Port 9087
- ✅ Database (192.168.10.61:1433) เข้าถึงได้
- ✅ Nginx/Apache ตั้งค่า Reverse Proxy แล้ว
- ✅ SSL Certificate ติดตั้งแล้ว (สำหรับ HTTPS)

---

## 🆘 แก้ปัญหา

### แอปไม่ทำงาน
```bash
# ดู logs
sudo journalctl -u go-lead -f

# Restart service
sudo systemctl restart go-lead
```

### Database connection error
ตรวจสอบ connection string ที่บรรทัด 101 ในไฟล์ `main.go`

### Port ถูกใช้แล้ว
```bash
# ดูว่าโปรแกรมไหนใช้ port 9087
sudo lsof -i :9087
# หรือ
sudo netstat -tlnp | grep 9087
```
