Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs and add diagram of request processing #344

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 28 additions & 18 deletions doc/standalone.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@

You don't need to install anything, to start using *cheat.sh*.
The only tool that you need is *curl*, which is typically installed
in every system. In the rare cases when *curl* is not installed,
there should be one of its alternatives in the system: *wget*, *wget2*,
*httpie*, *ftp* (with HTTP support), *fetch*, etc.
*cheat.sh* consists of server with cheat sheets, and *cht.sh* cli script that
fetches results from http server using `curl`. The default server https://cht.sh
also fetches and caches answers from StackOverflow.

There are two cases, when you want to install *cheat.sh* locally:
There are two cases, when you want to install *cheat.sh* server locally:

1. You plan to use it off-line, without Internet access;
2. You want to use your own cheat sheets (additionally, or as a replacement).

In this case you need to install cheat.sh locally.

## How to install cheat.sh locally
## How to install cheat.sh server

To use cheat.sh offline, you need to:

1. Install it,
2. Fetch its data sources.
1. Download cht.sh script,
2. Run standalone install command,
3. Fetch data sources.

If you already have the cht.sh cli client locally,
you can use it for the standalone installation.
Expand All @@ -28,17 +25,15 @@ Otherwise it must be installed first.
chmod +x ~/bin/cht.sh
```

Now you can install cheat.sh locally:
Now you can install cheat.sh server locally:

```
cht.sh --standalone-install
```

During the installation process, cheat.sh and its
data sources will be installed locally.

By default `~/.cheat.sh` is used as the installation
directory.
directory, which will also contain config and data
sources.

![cheat.sh standalone installation](https://user-images.githubusercontent.com/3875145/57986904-ef3f1b80-7a7a-11e9-9531-ef37ec74b03a.png)

Expand Down Expand Up @@ -67,7 +62,7 @@ Ideally, add it to *cron*:
In this example, all information sources will be updated
each day at 5:00 local time, on regular basis.

## cheat.sh server mode
## Running cheat.sh server

Your local cheat.sh installation is full-fledged, and it can
handle incoming HTTP/HTTPS queries.
Expand All @@ -80,10 +75,25 @@ $HOME/.cheat.sh/ve/bin/python $HOME/.cheat.sh/bin/srv.py

You can also use `gunicorn` to start the cheat.sh server.

### Request processing

For development you might be you're interested to know how
the request processing works,

```mermaid
sequenceDiagram
bin/srv.py->>gevent.pywsgi: patch_all()
Note right of bin/srv.py: startup initialization
loop servicing requests
gevent.pywsgi->>app.answer: /path:topic
app.answer-->>cheat_wrapper: query, format
cheat_wrapper-->>fronted.html.visualize: answer_data
end
```

## Docker

You can deploy cheat.sh as a docker container.
`cheat.sh` can also be deployed as a docker container.
Use `Dockerfile` in the source root directory, to build the Docker image:

```
Expand Down