Skip to content

Commit

Permalink
add examples
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Wall committed Dec 5, 2023
1 parent c86aed3 commit abf5502
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ haproxy-cli - A tool to interact with HAProxy.
1. [Install](#install)
1. [Modes](#modes)
1. [CLI Usage](#cli-usage)
1. [Examples](#examples)
- [CLI](#cli)
- [API](#api)
1. [Development](#development)
- [Contributing](#contributing)

Expand Down Expand Up @@ -67,6 +70,42 @@ optional arguments:
for protocol, then it assumes a UNIX socket file.
```

## Examples

### CLI

```
$ haproxy-cli -c frontends
$ haproxy-cli -c servers -b testing_backend
$ haproxy-cli -c get-weight -b example_backend -s server1
$ haproxy-cli -c set-weight -b example_backend -s server1 -w 99
$ haproxy-cli -k /run/haproxy/admin.sock -c backends
```

### API

```
#!/usr/bin/env python
from haproxy.conn import HaPConn
from haproxy import cmds
try:
socket_conn = HaPConn('/var/run/haproxy.socket')
if socket_conn:
print(socket_conn.sendCmd(cmds.showInfo()))
else:
print('Could not open socket')
except Exception as exc:
print(exc)
```

## Development

### Contributing
Expand Down

0 comments on commit abf5502

Please sign in to comment.