Skip to main content

REPL

The REPL was created to give a more fluid flow when executing commands remotely. It allows switching between targets and evaluating tasks more quickly. This is very useful when you need to inspect an inner system to understand its state, or why a program is not behaving as expected.

Requirements#

npm -g install runops
runops login

Start the REPL#

runops tasks repl
REPL started, each command will be executed remotely
and displayed in this session. https://runops.io/docs/concepts/tasks#repl
Type :help to list available commands
=>

Interacting with the REPL#

Typing :help will show a quick guide about the known commands

=> :help
COMMANDS
:help issue this help
:target <name> set a target to run commands
HOTKEYS
ctrl+e toogle to multiline prompt, on second toogle evaluates the command
ctrl+c cancel the multiline evaluation or exits REPL
USAGE
Each command executed is processed straight from REPL and processed remotely.
This is the default mode, pressing ctrl+e will toogle to the multiline which
could be evaluated pressing ctrl+e again.
The :target command will allow selecting a specific target to run a command.
A complete guide is available at https://runops.io/docs/concepts/tasks#repl

Each command is evaluated remotely after you hit enter

=>
=> foo
no target set, run :target <name>

A target must be set before evaluating commands, type :target your-target

=> :target mysql-read
mysql-read=>

We have set mysql-read target, now it's possible to issue MySQL commands

mysql-read=> SHOW TABLES
Tables_in_customers
orgs_test
users
mysql-read=> EXPLAIN users
Field Type Null Key Default Extra
id int(11) NO PRI NULL auto_increment
name varchar(100) NO NULL
email varchar(100) NO NULL
role varchar(100) YES NULL
type varchar(100) YES NULL

You could also write multiline statements pressing ctrl+e to activate it. To evaluate, press the hotkey again and hit enter.

mysql-read=>
#_=> SELECT id, name, email, role FROM users
#_=> WHERE name LIKE '%Jhon%'
#_=> AND role = 'SRE';
#_=>
id name email role
11 Jhonn Rambo *****.rambo@sylvester.tld SRE

If you want to change target and starting evaluating another service, issue :target your-new-target

mysql-read=> :target k8s
=> :target k8s
k8s=> get po -n kube-system
NAME READY STATUS RESTARTS AGE
(...)
kube-dns-6c7b8dc9f9-krzdb 4/4 Running 0 15d
kube-dns-6c7b8dc9f9-t29kd 4/4 Running 0 15d
kube-dns-autoscaler-844c9d9448-cdgrw 1/1 Running 0 15d
k8s=> logs kube-dns-6c7b8dc9f9-krzdb -n kube-system -ckubedns --tail=5
Trace[1266430231]: [10.001311582s] [10.001311582s] END
E0818 05:16:02.889957 1 reflector.go:125] pkg/mod/*****o/client-go@v0.0.0-20190620085101-78d2af792bab/tools/cache/reflector.go:98: Failed to list *v1.Service: Get *****://10.200.0.1:443/api/v1/services?limit=500&resourceVersion=0*****6.0.1:443: net/http: TLS handshake timeout
I0818 05:16:03.067556 1 trace.go:201] Trace[*****88708]: "Reflector pkg/mod/*****o/client-go@v0.0.0-20190620085101-78d2af792bab/tools/cache/reflector.go:98 ListAndWatch" (18-Aug-2021 05:15:00.066) (total time: 10001ms):
Trace[*****88708]: [10.001018784s] [10.001018784s] END
E0818 05:16:03.067588 1 reflector.go:125] pkg/mod/*****o/client-go@v0.0.0-20190620085101-78d2af792bab/tools/cache/reflector.go:98: Failed to list *v1.Endpoints: Get *****://10.200.0.1:443/api/v1/endpoints?limit=500&resourceVersion=0*****6.0.1:443: net/http: TLS handshake timeout

To exit from REPL issue the hotkey ctrl+c, it also exits from multiline prompt if it's toogled.

Custom markup