> For the complete documentation index, see [llms.txt](https://docs.hipersnipe.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.hipersnipe.com/for-operators/running-the-bot.md).

# Running the bot

## Recommended: unified launcher

```bash
python start_bot.py
```

`start_bot.py` spawns:

1. **Bot UI** — `main.py` (Telegram handlers, listeners, background tasks)
2. **Limit engine** — `limit_engine.py` (limit orders, Trading Shield, WSS price oracle)

Both processes share `users.db` in WAL mode. Ctrl+C triggers graceful shutdown of both.

## Bot only

```bash
python main.py
```

Use when debugging Telegram handlers. **Note:** `main.py` also starts `start_limit_engine(bot)` inline at boot (lines 746–750), so limit orders and Trading Shield **will** run in the same process. For production, prefer `start_bot.py` which isolates the limit engine in a separate process for resilience.

## Limit engine only

```bash
python limit_engine.py
```

Use for testing price subscriptions and order triggers in isolation.

## Production (systemd)

Example unit file:

```ini
[Unit]
Description=HiperSnipe Solana Telegram Bot
After=network.target

[Service]
Type=simple
User=ubuntu
WorkingDirectory=/opt/HiperSnipeBot_Solana_Python
ExecStart=/opt/HiperSnipeBot_Solana_Python/venv/bin/python start_bot.py
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1

[Install]
WantedBy=multi-user.target
```

Enable and start:

```bash
sudo systemctl daemon-reload
sudo systemctl enable solana-bot
sudo systemctl start solana-bot
sudo journalctl -u solana-bot -f
```

## Process model

```
start_bot.py
├── main.py          ← aiogram dispatcher, handlers, deposit listener
└── limit_engine.py  ← WSS subscriptions, TP/SL, limit order execution
```

Background tasks started from `main.py` include:

* Deposit listener
* Copy-trade listener
* DCA engine
* Pump watcher / snipe watcher
* Daily leaderboard broadcast (when `COMMUNITY_CHAT_ID` is set)
* TG scraper (when Telethon session is configured)

## Health checks

| Signal                                     | Healthy                 |
| ------------------------------------------ | ----------------------- |
| `bot.log` shows `Update id=... is handled` | Telegram polling works  |
| `[LIMIT ENGINE] WSS Health` metrics        | Price stream active     |
| `users.db` writable                        | DB migrations succeeded |

## Next steps

* [Monitoring and logs](/for-operators/monitoring.md)
* [Troubleshooting](/for-operators/troubleshooting.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.hipersnipe.com/for-operators/running-the-bot.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
