> 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/maintenance-mode.md).

# Maintenance mode

Maintenance mode silently drops non-admin Telegram updates during deployments or graceful shutdown.

## How it works

`middleware/maintenance.py` checks for:

1. **`.maintenance_lock` file** in the project root (created by `deploy.sh` / `restart_bot.py`)
2. **In-process shutdown flag** during graceful stop

When active, regular users' messages and callbacks are dropped with **no user-visible error**. Admins (`ADMIN_USER_IDS`) continue to operate normally.

## Lock file

| Path                | Purpose                        |
| ------------------- | ------------------------------ |
| `.maintenance_lock` | Signals deployment in progress |

Removed automatically on successful bot startup via `clear_maintenance_lock_file()`.

## Security telemetry

When maintenance blocks a non-admin update, `middleware/security_telemetry.py` can DM admins with telemetry (update type, user id) for visibility during incidents.

## Operator workflow

### Deploy with lock

```bash
# deploy.sh typically:
touch .maintenance_lock
# restart processes
# bot clears lock on healthy startup
```

### Manual lock (emergency)

```bash
touch /opt/HiperSnipeBot_Solana_Python/.maintenance_lock
```

Remove after restart:

```bash
rm /opt/HiperSnipeBot_Solana_Python/.maintenance_lock
```

Or let the bot clear it on startup.

## Hard reboot

Admin main menu → **Hard Reboot** runs `restart_bot.py`, which coordinates child process shutdown and sets maintenance state during the transition.

## Related

* [Deployment](/for-operators/deployment.md)
* [Troubleshooting](/for-operators/troubleshooting.md)
* [Admin commands reference](/admin/commands-reference.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/maintenance-mode.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.
