Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6b36549

Browse files
authoredMar 19, 2025··
update curio cli flags (#441)
1 parent a138a9f commit 6b36549

File tree

16 files changed

+930
-812
lines changed

16 files changed

+930
-812
lines changed
 

‎apt/DEBIAN/postinst

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ case "$1" in
1515
mkdir -p "/var/log/curio"
1616
fi
1717
if [ ! -f "/etc/curio.env" ]; then
18-
echo "CURIO_LAYERS=gui,post\nCURIO_ALL_REMAINING_FIELDS_ARE_OPTIONAL=true\nCURIO_DB_HOST=yugabyte\nCURIO_DB_USER=yugabyte\nCURIO_DB_PASSWORD=yugabyte\nCURIO_DB_PORT=5433\nCURIO_DB_NAME=yugabyte\nCURIO_REPO_PATH=~/.curio\nCURIO_NODE_NAME=ChangeMe\nFIL_PROOFS_USE_MULTICORE_SDR=1" >/etc/curio.env
18+
echo "CURIO_LAYERS=gui,post\nCURIO_ALL_REMAINING_FIELDS_ARE_OPTIONAL=true\nCURIO_DB_HOST=yugabyte\nCURIO_DB_USER=yugabyte\nCURIO_DB_PASSWORD=yugabyte\nCURIO_DB_PORT=5433\nCURIO_DB_NAME=yugabyte\nCURIO_DB_CASSANDRA_PORT=9042\nCURIO_REPO_PATH=~/.curio\nCURIO_NODE_NAME=ChangeMe\nFIL_PROOFS_USE_MULTICORE_SDR=1" >/etc/curio.env
1919
echo "setup /etc/curio.env then run: systemctl start curio.service"
2020
fi
2121
else

‎cmd/curio/guidedsetup/guidedsetup.go

+11-13
Original file line numberDiff line numberDiff line change
@@ -208,14 +208,11 @@ func complete(d *MigrationData) {
208208
stepCompleted(d, d.T("Lotus-Miner to Curio Migration."))
209209
}
210210

211-
var EnvFiles = []string{"/etc/curio.env", "./curio/curio.env", "~/config/curio.env"}
212-
213211
func afterRan(d *MigrationData) {
214-
// Write curio.env file.
215-
// Inform users they need to copy this to /etc/curio.env or ~/.config/curio.env to run Curio.
216-
places := append([]string{"/tmp/curio.env",
212+
// Write curio.env file for user's reference
213+
places := []string{"/tmp/curio.env",
217214
must.One(os.Getwd()) + "/curio.env",
218-
must.One(os.UserHomeDir()) + "/curio.env"}, EnvFiles...)
215+
must.One(os.UserHomeDir()) + "/curio.env"}
219216
saveConfigFile:
220217
_, where, err := (&promptui.Select{
221218
Label: d.T("Where should we save your database config file?"),
@@ -227,15 +224,16 @@ saveConfigFile:
227224
os.Exit(1)
228225
}
229226

230-
args := []string{fmt.Sprintf("CURIO_DB=postgres://%s:%s@%s:%s/%s",
231-
d.HarmonyCfg.Username,
232-
d.HarmonyCfg.Password,
233-
d.HarmonyCfg.Hosts[0],
234-
d.HarmonyCfg.Port,
235-
d.HarmonyCfg.Database)}
227+
lines := []string{
228+
fmt.Sprintf("export CURIO_DB_HOST=%s", strings.Join(d.HarmonyCfg.Hosts, ",")),
229+
fmt.Sprintf("export CURIO_DB_USER=%s", d.HarmonyCfg.Username),
230+
fmt.Sprintf("export CURIO_DB_PASSWORD=%s", d.HarmonyCfg.Password),
231+
fmt.Sprintf("export CURIO_DB_PORT=%s", d.HarmonyCfg.Port),
232+
fmt.Sprintf("export CURIO_DB_NAME=%s", d.HarmonyCfg.Database),
233+
}
236234

237235
// Write the file
238-
err = os.WriteFile(where, []byte(strings.Join(args, "\n")), 0644)
236+
err = os.WriteFile(where, []byte(strings.Join(lines, "\n")), 0644)
239237
if err != nil {
240238
d.say(notice, "Error writing file: %s", err.Error())
241239
goto saveConfigFile

‎cmd/curio/internal/translations/catalog.go

+726-704
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎cmd/curio/internal/translations/locales/en/out.gotext.json

+35
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,41 @@
351351
"translatorComment": "Copied from source.",
352352
"fuzzy": true
353353
},
354+
{
355+
"id": "Name of the Postgres database in Yugabyte cluster",
356+
"message": "Name of the Postgres database in Yugabyte cluster",
357+
"translation": "Name of the Postgres database in Yugabyte cluster",
358+
"translatorComment": "Copied from source.",
359+
"fuzzy": true
360+
},
361+
{
362+
"id": "Username for connecting to the Postgres database in Yugabyte cluster",
363+
"message": "Username for connecting to the Postgres database in Yugabyte cluster",
364+
"translation": "Username for connecting to the Postgres database in Yugabyte cluster",
365+
"translatorComment": "Copied from source.",
366+
"fuzzy": true
367+
},
368+
{
369+
"id": "Password for connecting to the Postgres database in Yugabyte cluster",
370+
"message": "Password for connecting to the Postgres database in Yugabyte cluster",
371+
"translation": "Password for connecting to the Postgres database in Yugabyte cluster",
372+
"translatorComment": "Copied from source.",
373+
"fuzzy": true
374+
},
375+
{
376+
"id": "Port for connecting to the Postgres database in Yugabyte cluster",
377+
"message": "Port for connecting to the Postgres database in Yugabyte cluster",
378+
"translation": "Port for connecting to the Postgres database in Yugabyte cluster",
379+
"translatorComment": "Copied from source.",
380+
"fuzzy": true
381+
},
382+
{
383+
"id": "Port for connecting to the Cassandra database in Yugabyte cluster",
384+
"message": "Port for connecting to the Cassandra database in Yugabyte cluster",
385+
"translation": "Port for connecting to the Cassandra database in Yugabyte cluster",
386+
"translatorComment": "Copied from source.",
387+
"fuzzy": true
388+
},
354389
{
355390
"id": "enables very verbose mode, useful for debugging the CLI",
356391
"message": "enables very verbose mode, useful for debugging the CLI",

‎cmd/curio/internal/translations/locales/ko/messages.gotext.json

+30
Original file line numberDiff line numberDiff line change
@@ -2061,6 +2061,36 @@
20612061
"translation": "JSON 형식으로 출력",
20622062
"message": "output in json format",
20632063
"placeholder": null
2064+
},
2065+
{
2066+
"id": "Name of the Postgres database in Yugabyte cluster",
2067+
"translation": "Yugabyte 클러스터의 Postgres 데이터베이스 이름",
2068+
"message": "Name of the Postgres database in Yugabyte cluster",
2069+
"placeholder": null
2070+
},
2071+
{
2072+
"id": "Username for connecting to the Postgres database in Yugabyte cluster",
2073+
"translation": "Yugabyte 클러스터의 Postgres 데이터베이스에 연결하기 위한 사용자 이름",
2074+
"message": "Username for connecting to the Postgres database in Yugabyte cluster",
2075+
"placeholder": null
2076+
},
2077+
{
2078+
"id": "Password for connecting to the Postgres database in Yugabyte cluster",
2079+
"translation": "Yugabyte 클러스터의 Postgres 데이터베이스에 연결하기 위한 비밀번호",
2080+
"message": "Password for connecting to the Postgres database in Yugabyte cluster",
2081+
"placeholder": null
2082+
},
2083+
{
2084+
"id": "Port for connecting to the Postgres database in Yugabyte cluster",
2085+
"translation": "Yugabyte 클러스터의 Postgres 데이터베이스에 연결하기 위한 포트",
2086+
"message": "Port for connecting to the Postgres database in Yugabyte cluster",
2087+
"placeholder": null
2088+
},
2089+
{
2090+
"id": "Port for connecting to the Cassandra database in Yugabyte cluster",
2091+
"translation": "Yugabyte 클러스터의 Cassandra 데이터베이스에 연결하기 위한 포트",
2092+
"message": "Port for connecting to the Cassandra database in Yugabyte cluster",
2093+
"placeholder": null
20642094
}
20652095
]
20662096
}

‎cmd/curio/internal/translations/locales/zh/messages.gotext.json

+30
Original file line numberDiff line numberDiff line change
@@ -2031,6 +2031,36 @@
20312031
"translation": "以 JSON 格式输出",
20322032
"message": "output in json format",
20332033
"placeholder": null
2034+
},
2035+
{
2036+
"id": "Name of the Postgres database in Yugabyte cluster",
2037+
"translation": "Yugabyte 集群中 Postgres 数据库的名称",
2038+
"message": "Name of the Postgres database in Yugabyte cluster",
2039+
"placeholder": null
2040+
},
2041+
{
2042+
"id": "Username for connecting to the Postgres database in Yugabyte cluster",
2043+
"translation": "连接 Yugabyte 集群中 Postgres 数据库的用户名",
2044+
"message": "Username for connecting to the Postgres database in Yugabyte cluster",
2045+
"placeholder": null
2046+
},
2047+
{
2048+
"id": "Password for connecting to the Postgres database in Yugabyte cluster",
2049+
"translation": "连接 Yugabyte 集群中 Postgres 数据库的密码",
2050+
"message": "Password for connecting to the Postgres database in Yugabyte cluster",
2051+
"placeholder": null
2052+
},
2053+
{
2054+
"id": "Port for connecting to the Postgres database in Yugabyte cluster",
2055+
"translation": "连接 Yugabyte 集群中 Postgres 数据库的端口",
2056+
"message": "Port for connecting to the Postgres database in Yugabyte cluster",
2057+
"placeholder": null
2058+
},
2059+
{
2060+
"id": "Port for connecting to the Cassandra database in Yugabyte cluster",
2061+
"translation": "连接 Yugabyte 集群中 Cassandra 数据库的端口",
2062+
"message": "Port for connecting to the Cassandra database in Yugabyte cluster",
2063+
"placeholder": null
20342064
}
20352065
]
20362066
}

‎cmd/curio/main.go

+10
Original file line numberDiff line numberDiff line change
@@ -133,23 +133,33 @@ func main() {
133133
&cli.StringFlag{
134134
Name: "db-name",
135135
EnvVars: []string{"CURIO_DB_NAME", "CURIO_HARMONYDB_NAME"},
136+
Usage: translations.T("Name of the Postgres database in Yugabyte cluster"),
136137
Value: "yugabyte",
137138
},
138139
&cli.StringFlag{
139140
Name: "db-user",
141+
Usage: translations.T("Username for connecting to the Postgres database in Yugabyte cluster"),
140142
EnvVars: []string{"CURIO_DB_USER", "CURIO_HARMONYDB_USERNAME"},
141143
Value: "yugabyte",
142144
},
143145
&cli.StringFlag{
144146
Name: "db-password",
147+
Usage: translations.T("Password for connecting to the Postgres database in Yugabyte cluster"),
145148
EnvVars: []string{"CURIO_DB_PASSWORD", "CURIO_HARMONYDB_PASSWORD"},
146149
Value: "yugabyte",
147150
},
148151
&cli.StringFlag{
149152
Name: "db-port",
153+
Usage: translations.T("Port for connecting to the Postgres database in Yugabyte cluster"),
150154
EnvVars: []string{"CURIO_DB_PORT", "CURIO_HARMONYDB_PORT"},
151155
Value: "5433",
152156
},
157+
&cli.IntFlag{
158+
Name: "db-cassandra-port",
159+
Usage: translations.T("Port for connecting to the Cassandra database in Yugabyte cluster"),
160+
EnvVars: []string{"CURIO_DB_CASSANDRA_PORT", "CURIO_INDEXDB_PORT"},
161+
Value: 9042,
162+
},
153163
&cli.StringFlag{
154164
Name: deps.FlagRepoPath,
155165
EnvVars: []string{"CURIO_REPO_PATH"},

‎deps/deps.go

+5-29
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"io"
1313
"net"
1414
"net/http"
15-
"net/url"
1615
"os"
1716
"path"
1817
"path/filepath"
@@ -97,40 +96,17 @@ func MakeDB(cctx *cli.Context) (*harmonydb.DB, error) {
9796
}
9897
return readToml(filepath.Join(u, ".lotusminer/config.toml"))
9998
}
100-
fromEnv := func() (*harmonydb.DB, error) {
101-
// #3 Try env
102-
u, err := url.Parse(os.Getenv("CURIO_DB"))
103-
if err != nil {
104-
return nil, errors.New("no db connection string found in CURIO_DB env")
105-
}
106-
cfg := config.DefaultStorageMiner().HarmonyDB
107-
if u.User.Username() != "" {
108-
cfg.Username = u.User.Username()
109-
}
110-
if p, ok := u.User.Password(); ok && p != "" {
111-
cfg.Password = p
112-
}
113-
if u.Hostname() != "" {
114-
cfg.Hosts = []string{u.Hostname()}
115-
}
116-
if u.Port() != "" {
117-
cfg.Port = u.Port()
118-
}
119-
if strings.TrimPrefix(u.Path, "/") != "" {
120-
cfg.Database = strings.TrimPrefix(u.Path, "/")
121-
}
122-
123-
return harmonydb.NewFromConfig(cfg)
124-
}
12599

126-
for _, f := range []func() (*harmonydb.DB, error){fromCLI, fromMinerEnv, fromMiner, fromEnv} {
100+
for _, f := range []func() (*harmonydb.DB, error){fromCLI, fromMinerEnv, fromMiner} {
127101
db, err := f()
128102
if err != nil {
129103
continue
130104
}
131105
return db, nil
132106
}
133-
log.Error("No db connection string found. User CLI args or env var: set CURIO_DB=postgres://USER:PASSWORD@HOST:PORT/DATABASE")
107+
log.Error("Could not connect to db. Please verify that your YugabyteDB is running and the env vars or CLI args are correct.")
108+
log.Error("If running as a service, please ensure that the service is running with the correct env vars in /etc/curio.env file.")
109+
log.Error("If running locally, please ensure that the env vars are set correctly in your shell. Run `curio --help` for more info.")
134110
return fromCLI() //in-case it's not about bad config.
135111
}
136112

@@ -365,7 +341,7 @@ Get it with: jq .PrivateKey ~/.lotus-miner/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU`,
365341
}
366342

367343
if deps.IndexStore == nil {
368-
deps.IndexStore, err = indexstore.NewIndexStore(strings.Split(cctx.String("db-host"), ","), deps.Cfg)
344+
deps.IndexStore, err = indexstore.NewIndexStore(strings.Split(cctx.String("db-host"), ","), cctx.Int("db-cassandra-port"), deps.Cfg)
369345
if err != nil {
370346
return xerrors.Errorf("failed to start index store: %w", err)
371347
}

‎documentation/en/curio-cli/curio.md

+11-10
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,17 @@ COMMANDS:
2424
help, h Shows a list of commands or help for one command
2525
2626
GLOBAL OPTIONS:
27-
--color use color in display output (default: depends on output being a TTY)
28-
--db-host value Command separated list of hostnames for yugabyte cluster (default: "127.0.0.1") [$CURIO_DB_HOST, $CURIO_HARMONYDB_HOSTS]
29-
--db-name value (default: "yugabyte") [$CURIO_DB_NAME, $CURIO_HARMONYDB_NAME]
30-
--db-user value (default: "yugabyte") [$CURIO_DB_USER, $CURIO_HARMONYDB_USERNAME]
31-
--db-password value (default: "yugabyte") [$CURIO_DB_PASSWORD, $CURIO_HARMONYDB_PASSWORD]
32-
--db-port value (default: "5433") [$CURIO_DB_PORT, $CURIO_HARMONYDB_PORT]
33-
--repo-path value (default: "~/.curio") [$CURIO_REPO_PATH]
34-
--vv enables very verbose mode, useful for debugging the CLI (default: false)
35-
--help, -h show help
36-
--version, -v print the version
27+
--color use color in display output (default: depends on output being a TTY)
28+
--db-host value Command separated list of hostnames for yugabyte cluster (default: "127.0.0.1") [$CURIO_DB_HOST, $CURIO_HARMONYDB_HOSTS]
29+
--db-name value Name of the Postgres database in Yugabyte cluster (default: "yugabyte") [$CURIO_DB_NAME, $CURIO_HARMONYDB_NAME]
30+
--db-user value Username for connecting to the Postgres database in Yugabyte cluster (default: "yugabyte") [$CURIO_DB_USER, $CURIO_HARMONYDB_USERNAME]
31+
--db-password value Password for connecting to the Postgres database in Yugabyte cluster (default: "yugabyte") [$CURIO_DB_PASSWORD, $CURIO_HARMONYDB_PASSWORD]
32+
--db-port value Port for connecting to the Postgres database in Yugabyte cluster (default: "5433") [$CURIO_DB_PORT, $CURIO_HARMONYDB_PORT]
33+
--db-cassandra-port value Port for connecting to the Cassandra database in Yugabyte cluster (default: 9042) [$CURIO_DB_CASSANDRA_PORT, $CURIO_INDEXDB_PORT]
34+
--repo-path value (default: "~/.curio") [$CURIO_REPO_PATH]
35+
--vv enables very verbose mode, useful for debugging the CLI (default: false)
36+
--help, -h show help
37+
--version, -v print the version
3738
```
3839

3940
## curio cli

‎documentation/en/curio-service.md

+17-1
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,28 @@ CURIO_DB_USER=yugabyte
4646
CURIO_DB_PASSWORD=yugabyte
4747
CURIO_DB_PORT=5433
4848
CURIO_DB_NAME=yugabyte
49+
CURIO_DB_CASSANDRA_PORT=9042
4950
CURIO_REPO_PATH=~/.curio
5051
CURIO_NODE_NAME=ChangeMe
5152
FIL_PROOFS_USE_MULTICORE_SDR=1
5253
```
5354

54-
Ensure all variables are correctly set according to your environment. Additionally you can also export the following variable for cache location.
55+
| Variable | Description | Example Value |
56+
|----------|------------------------------------------------------------------------------------------------------------------------------------------------------|----------------|
57+
| `CURIO_LAYERS` | Config layers to be stacked and used for this Curio node | `gui,post` |
58+
| `CURIO_ALL_REMAINING_FIELDS_ARE_OPTIONAL` | Allows optional fields to use defaults. This ensures that missing configurations are not treated as errors, instead, they will be assigned defaults | `true` |
59+
| `CURIO_DB_HOST` | Database hosts (comma-separated) for the YugabyteDB cluster | `yugabyte1,yugabyte2,yugabyte3` |
60+
| `CURIO_DB_USER` | Username for authenticating with YugabyteDB's Postgres Database defined by `CURIO_DB_NAME` | `yugabyte` |
61+
| `CURIO_DB_PASSWORD` | Password for the specified CURIO_DB_USER | `yugabyte` |
62+
| `CURIO_DB_PORT` | Port for YugabyteDB Postgres connection | `5433` |
63+
| `CURIO_DB_NAME` | Name of the PostgreSQL database in YugabyteDB | `yugabyte` |
64+
| `CURIO_DB_CASSANDRA_PORT` | Port for YugabyteDB Cassandra connection | `9042` |
65+
| `CURIO_REPO_PATH` | Directory for Curio storage configuration `json` file | `~/.curio` |
66+
| `CURIO_NODE_NAME` | Name of the Curio node | `ChangeMe` |
67+
| `FIL_PROOFS_USE_MULTICORE_SDR` | Enables multi-core SDR in Filecoin | `1` |
68+
69+
70+
Ensure all variables are correctly set according to your environment. Additionally, you can also export the following variable for cache location.
5571

5672
```sh
5773
FIL_PROOFS_PARAMETER_CACHE=/path/to/folder/in/fast/disk

0 commit comments

Comments
 (0)
Please sign in to comment.