# การ Run Bot

หลังจากที่เราตั้งค่า Configuration ต่าง ๆ เสร็จเรียบร้อยแล้ว ต่อมา เรามา Start ให้ Bot เริ่มทำงานกันดีกว่า

## แบบ Simple

ให้ Run คำสั่ง Docker run ดังนี้

```bash
$ docker run -d \
  -p 8080:8080 \
  -v $PWD:/iwallet \
  --restart=always \
  --name iwallet ghcr.io/jittagornp/iwallet
```

**หมายเหตุ**&#x20;

* อย่าลืม Change Directory ให้อยู่ที่ Directory `iwallet` ที่เราสร้างไว้ก่อนหน้านี้ ก่อน Run คำสั่งน่ะ เพราะ Bot จะอ่านค่า Configuration ต่าง ๆ และเก็บข้อมูลต่าง ๆ ลงใน  Directory นี้&#x20;
* เวอร์ชัน Free เปลี่ยน Repository จาก  `ghcr.io/jittagornp/iwallet` เป็น `jittagornp/iwallet`

#### การเช็คว่า Bot ทำงานหรือไม่

ลองใช้คำสั่ง

```bash
$ docker ps -a
```

ถ้า Bot ทำงาน ตรง STATUS จะเป็น `Up` ดังนี้

```bash
CONTAINER ID   IMAGE                        COMMAND               CREATED       STATUS       PORTS                                   NAMES
e6599daa70d2   ghcr.io/jittagornp/iwallet   "sh /entrypoint.sh"   2 hours ago   Up 2 hours   0.0.0.0:80->8080/tcp, :::80->8080/tcp   iwallet
```

ลองดู Log การทำงานของ Container ด้วยคำสั่ง

```bash
$ docker logs -f iwallet
```

ถ้าจะออกจาก Log ให้กด Ctrl + c

#### เปิดหน้า UI

ลองเปิด Browser เช่น Google Chrome แล้วไปที่ URL [http://localhost:8080](http://localhost:8080/)

จะขึ้นเป็นหน้า Login แบบนี้ (ถ้าไม่ขึ้น ให้รอ 10 - 30 วินาที)

![](/files/-Mhi5fkksbkW0Steqdn9)

ลอง Login ด้วย Your Secret เป็น `password` ดู

![](/files/-MhiB50MJmIfeLQBLVqc)

## แบบ Advance

ให้ Run คำสั่ง Docker run ดังนี้

```bash
$ docker run -d \
  -p 8080:8080 \
  -v $PWD:/iwallet \
  -e IWALLET_DATABASE_USERNAME="<YOUR_DATABASE_USERNAME>" \
  -e IWALLET_DATABASE_PASSWORD="<YOUR_DATABASE_PASSWORD>" \
  -e IWALLET_APP_SECRET="<YOUR_APP_SECRET>" \
  -e IWALLET_ALLOW_DOMAINS="<YOUR_DOMAIN_NAME>" \
  --restart=always \
  --name iwallet ghcr.io/jittagornp/iwallet
```

**หมายเหตุ**&#x20;

* เวอร์ชัน Free เปลี่ยน Repository จาก  `ghcr.io/jittagornp/iwallet` เป็น `jittagornp/iwallet`&#x20;
* ถ้า Run ไม่ขึ้น ให้ลองลบ Directory database แล้วลอง Run ใหม่ดู (อาจจะเพราะมีการเปลี่ยน Database Username เลยทำให้ Start ไม่ขึ้น)&#x20;

#### คำอธิบาย

| Environment Variable        | Description                                                                                                                                                                                                                                                                   |  Default |
| --------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: |
| IWALLET\_DATABASE\_USERNAME | บัญชีผู้ใช้สำหรับเข้าถึงฐานข้อมูล                                                                                                                                                                                                                                             |  iwallet |
| IWALLET\_DATABASE\_PASSWORD | รหัสผ่านสำหรับเข้าถึงฐานข้อมูล                                                                                                                                                                                                                                                | password |
| IWALLET\_APP\_SECRET        | รหัสผ่านสำหรับเข้า Application (iWallet)                                                                                                                                                                                                                                      | password |
| IWALLET\_ALLOW\_DOMAINS     | <p>กำหนดให้เข้าถึงได้ผ่าน Domain Name ที่อนุญาตเท่านั้น <br>สามารถกำหนดได้หลาย Domains โดยใช้ <code>,</code> คั่น เป็น <code>domain1, domain2, domain3</code> Domain ต้องไม่มี <code>http</code> หรือ <code>https</code> นำหน้า เช่น <code>iwallet.jittagornp.me</code>  </p> |     -    |

## คำแนะนำ

ถ้าจะใช้งานจริง แนะนำให้&#x20;

**Run แบบ Advance และใช้ Two-Factor Authentication + LINE Notify ที่จะอธิบายในหัวข้อถัดไปด้วย เท่านั้น** \*\*

อย่าลืมกำหนด Secret/Password ต่าง ๆ ให้ปลอดภัย (Secure) ด้วยน่ะ


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://iwallet.jittagornp.me/installation/run-bot.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
