---
feature_story: FS_36_17_84_44
feature_title: check_env script
feature_status: TEST
---

# Purpose

Shell environment is too flexible in config to rely on it blindly
(e.g. it allows aliases to override any command).

There should be a script to check automatically and report any issues with the setup (to support user easily).

The script is supposed to provide single place to perform multi-level verification.

This script may overlap with verifications done by FS_85_33_46_53 `bootstrap_env`. <br/>
And, similar to `bootstrap_env`, `check_env` is installed to target integration project as a copy<br/>
so that it can be run on project clone before bootstrapping the environment.

# Idea

The set of checks to be performed should be open for extension by the target project.

It can start as Bash code (Bash-phase) by checking any pre-requisites to run Python code (Python-phase):
*   `@/conf/` symlink
*   Python version
*   `venv` existence
*   `argrelay` package existence
Then, it can continue as Python code (Python-phase) by checking anything else.

Guidelines:
*   Bash-phase executes (preferably) things until it is confirmed Python-phase is ready to execute.
*   As much as possible, checks should be implemented in Python-phase (as it is easier to test this logic).

# Implementation

Entry point:
*   It is started (both Bash-phase and Python-phase) by single script `@/exe/check_env.bash`.

Config files:

*   Plugins for Bash-phase are configured by `@/conf/check_env_plugin.conf.bash`.

    The entries there are simply paths to scripts to run.

*   Plugins for Python-phase are configured by `@/conf/check_env_plugin.conf.yaml`.

    The entries there are the same as any other plugin but extend `PluginCheckEnvAbstract`.

# Plans

Checks:
*   DONE: whether it is run under FS_58_61_77_69 `dev_shell`
*   check whether debug enabled and which debug (p, s, ... etc.).
*   whether `PATH` env var reaches client and server binaries
*   whether completion is configured in shell
*   DONE: `@/conf` locations used
*   DONE: any useful missing (or useless existing) settings in `~/.inputrc`
*   DONE: server availability
*   DONE: server version
*   server and client compatibility
*   prints server instance id and whatever we can query to verify its state
*   print plugin list (serialized DAG) with types and activation status
*   verify whether there is any issues between:
    *   client-side plugin config
    *   server-side plugin config
*   any useful `readline` settings set or not
*   DONE: FS_57_36_37_48 (multiple clients) show all registered clients
*   DONE: show all registered commands (FS_57_36_37_48 per client)
*   DONE: print the same line info what `@/exe/dev_shell.bash` prints about version, conf, URL, etc.

What else?

```
# TODO: Connect to server to get:
#       server instance id (UUID),
#       argrelay framework server version,
#       server start time,
#       server setup version,
#       server setup commit id,
#       etc.

# TODO: Check if server is local.
#       Do not check via hostname.
#       Simply check netstat against port number to select pid.
#       Check if pid file exists.
#       Check if pid in pid file matches pid from netstat.
#       Verify if localhost:server_port_number succeeds with the same server instance id.

# TODO: additionally:
#       show latest server log.
```
