mirror of
https://github.com/logseq/logseq.git
synced 2026-04-28 08:04:40 +00:00
003-db-worker-node-cli-orchestration.md (2)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Logseq CLI (Node)
|
||||
|
||||
The Logseq CLI is a Node.js program compiled from ClojureScript that connects to the db-worker-node server.
|
||||
The Logseq CLI is a Node.js program compiled from ClojureScript that connects to a db-worker-node server managed by the CLI.
|
||||
|
||||
## Build the CLI
|
||||
|
||||
@@ -8,17 +8,14 @@ The Logseq CLI is a Node.js program compiled from ClojureScript that connects to
|
||||
clojure -M:cljs compile logseq-cli
|
||||
```
|
||||
|
||||
## Start db-worker-node (in another terminal)
|
||||
## db-worker-node lifecycle
|
||||
|
||||
```bash
|
||||
clojure -M:cljs compile db-worker-node
|
||||
node ./static/db-worker-node.js
|
||||
```
|
||||
`logseq-cli` manages `db-worker-node` automatically. You should not start the server manually. The server binds to localhost on a random port and records that port in the repo lock file.
|
||||
|
||||
## Run the CLI
|
||||
|
||||
```bash
|
||||
node ./static/logseq-cli.js graph list --base-url http://127.0.0.1:9101
|
||||
node ./static/logseq-cli.js graph list
|
||||
```
|
||||
|
||||
## Configuration
|
||||
@@ -26,9 +23,9 @@ node ./static/logseq-cli.js graph list --base-url http://127.0.0.1:9101
|
||||
Optional configuration file: `~/.logseq/cli.edn`
|
||||
|
||||
Supported keys include:
|
||||
- `:base-url`
|
||||
- `:auth-token`
|
||||
- `:repo`
|
||||
- `:data-dir`
|
||||
- `:timeout-ms`
|
||||
- `:retries`
|
||||
- `:output-format` (use `:json` or `:edn` for scripting)
|
||||
@@ -39,11 +36,20 @@ CLI flags take precedence over environment variables, which take precedence over
|
||||
|
||||
Graph commands:
|
||||
- `graph list` - list all db graphs
|
||||
- `graph create --graph <name>` - create a new db graph and switch to it
|
||||
- `graph switch --graph <name>` - switch current graph
|
||||
- `graph remove --graph <name>` - remove a graph
|
||||
- `graph validate --graph <name>` - validate graph data
|
||||
- `graph info [--graph <name>]` - show graph metadata (defaults to current graph)
|
||||
- `graph create --repo <name>` - create a new db graph and switch to it
|
||||
- `graph switch --repo <name>` - switch current graph
|
||||
- `graph remove --repo <name>` - remove a graph
|
||||
- `graph validate --repo <name>` - validate graph data
|
||||
- `graph info [--repo <name>]` - show graph metadata (defaults to current graph)
|
||||
|
||||
For any command that requires `--repo`, if the target graph does not exist, the CLI returns `graph not exists` (except for `graph create`).
|
||||
|
||||
Server commands:
|
||||
- `server list` - list running db-worker-node servers
|
||||
- `server status --repo <name>` - show server status for a graph
|
||||
- `server start --repo <name>` - start db-worker-node for a graph
|
||||
- `server stop --repo <name>` - stop db-worker-node for a graph
|
||||
- `server restart --repo <name>` - restart db-worker-node for a graph
|
||||
|
||||
Block commands:
|
||||
- `block add --content <text> [--page <name>] [--parent <uuid>]` - add blocks; defaults to today’s journal page if no page is given
|
||||
@@ -71,8 +77,9 @@ Output formats:
|
||||
Examples:
|
||||
|
||||
```bash
|
||||
node ./static/logseq-cli.js graph create --graph demo --base-url http://127.0.0.1:9101
|
||||
node ./static/logseq-cli.js graph create --repo demo
|
||||
node ./static/logseq-cli.js block add --page TestPage --content "hello world"
|
||||
node ./static/logseq-cli.js block search --text "hello"
|
||||
node ./static/logseq-cli.js block tree --page TestPage --format json --output json
|
||||
node ./static/logseq-cli.js server list
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user