Reference

prompt

Initiate an interactive session with the Runtime API.

Description Jump to heading

Use prompt to you can begin an interactive session wherein you can enter commands without needing to reconnect to the API each time.

Examples Jump to heading

Start an interactive session Jump to heading

  1. Connect to the Runtime API socket:

    nix
    sudo socat stdio tcp4-connect:127.0.0.1:9999
    nix
    sudo socat stdio tcp4-connect:127.0.0.1:9999
  2. Start an interactive session:

    nix
    prompt
    nix
    prompt

Then you can send other Runtime API commands.

Show uptime Jump to heading

Available since

  • HAProxy 2.8
  • HAProxy Enterprise 2.8r1

Provide an additional argument timed to the prompt command which will show the process’ uptime on the prompt.

nix
sudo socat stdio tcp4-connect:127.0.0.1:9999
nix
sudo socat stdio tcp4-connect:127.0.0.1:9999
nix
prompt timed
nix
prompt timed

The prompt will then show with the process’ uptime.

output
text
[0:00:15:55]>
output
text
[0:00:15:55]>

Set interactive mode Jump to heading

Available since

  • HAProxy 3.2
  • HAProxy Enterprise 3.2r1

prompt has three modes: non-interactive, interactive, and interactive-prompt mode. Specify the mode after the prompt keyword. For example, prompt mode (p) prints a prompt and waits for a command. Once the command finishes, the prompt appears again:

nix
sudo socat stdio tcp4-connect:127.0.0.1:9999
prompt p
nix
sudo socat stdio tcp4-connect:127.0.0.1:9999
prompt p
output
text
> help
The following commands are valid at this level:
...
>
output
text
> help
The following commands are valid at this level:
...
>

The table below explains the differences:

Mode Option Description
non-interactive n Useful for basic scripts. The connection is closed after the command completes.
interactive i Useful for advanced scripts, such as monitoring scripts. The connection remains open after the command completes, but doesn’t print a prompt character (>).
prompt p Useful for human users. A prompt displays following each command and the connection remains open.

See also Jump to heading

Do you have any suggestions on how we can improve the content of this page?