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

Add Restate CLI docs #249

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
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
138 changes: 138 additions & 0 deletions docs/restate/cli.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
---
sidebar_position: 4
description: "Use the CLI to interact with Restate."
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# CLI

You can use the CLI to interact with Restate, and manage your services, deployments and invocations.

## Installation

Install the Restate CLI via:

<Tabs groupId="operating-systems">
<TabItem value="lin" label="npm">

```shell
npm install @restatedev/restate
```

</TabItem>
<TabItem value="mac" label="Homebrew">

```shell
brew install restatedev/tap/restate
```

</TabItem>
</Tabs>


## Configuration

There are two ways to configure the CLI: via environment variables or via a configuration file.

### Using environment variables

You can specify the following environment variables:

- `RESTATE_HOST`: The hostname/IP address of the server. Default is `localhost`.
- `RESTATE_HOST_SCHEME`: Default is `http`.
- `RESTATE_META_URL`: To specify the full URL of meta service (scheme+host+port).
- `RESTATE_DATAFUSION_HTTP_URL`: To specify the full URL of datafusion HTTP endpoint.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm very hesitant about exposing this as a "data fusion" thing. I would like to combine this with the META URL under one name "admin" URL. Let me work on this first.

- `RESTATE_AUTH_TOKEN`: Set if authentication is required.

For example, to specify the hostname `myhost` and the host scheme `https`, pass environment variables as follows:

```shell
RESTATE_HOST=myhost RESTATE_HOST_SCHEME=https restate <command>
```

### Using a configuration file

You can also specify the configuration in a `.env` file. The CLI will look for a `.env` file in its current directory.

For example, to connect to a Restate meta running at `http://myhost:7777`, save the following in a `.env` file:

```
RESTATE_META_URL=http://myhost:7777
```

## Usage

Here are a few useful commands:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested: restate whoami is a good way to know if your CLI is configured correctly or not.


**Check if the CLI is configured correctly**

```shell
restate whoami
```


**Printing help**

```shell
restate --help
```

**Downloading an example or template**

```shell
restate example
```

Follow the prompts to select which template you want to download.

**Listing your services**

```shell
restate svc list
```
Comment on lines +90 to +94
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very useful/powerful command is also restate svc status which can take an optional argument (service name) if you want to filter out the output by a specific service.

It shows running the summary of the service and counters for invocations in various states. Is also shows the a sample of service keys that has active ongoing invocations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, that is indeed a useful one! I added it.


**Show the status of the service(s)**

```shell
restate svc status
```

Shows a summary of the services and their methods.
It shows counters for the invocations in the various states (pending, running, suspended, etc.)
It also lists a sample of active service keys.

To print the status of a specific service:

```shell
restate svc status <SERVICE_NAME>
```

**Listing ongoing invocations**

```shell
restate inv list
```

**Describing the status of an invocation**

```shell
restate inv describe <INVOCATION_ID>
```

Use this command to understand the progress of the invocation: the status, any errors and retries that occurred, the current journal, etc.

**Cancel an ongoing invocation**

```shell
restate inv cancel <INVOCATION_ID>
```

Use this command to cancel an invocation and its children.
Use the `--kill` flag to ungracefully kill the invocation and its children.

:::tip
The CLI can be a useful tool for debugging and troubleshooting.
Have a look at the [introspection page](/services/introspection) for a list of useful commands .
:::
2 changes: 1 addition & 1 deletion docs/restate/logging.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 5
description: "Find out how to configure logging for Restate."
---

Expand Down
2 changes: 1 addition & 1 deletion docs/restate/managed_service.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 6
sidebar_position: 7
description: "Try out Restate without any servers."
---

Expand Down
2 changes: 1 addition & 1 deletion docs/restate/tracing.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 4
sidebar_position: 6
description: "Find out how to export traces of your invocations."
---

Expand Down
Loading