Skip to content

Commit 14a4d1d

Browse files
committed
More extended help
1 parent c837c7e commit 14a4d1d

File tree

2 files changed

+64
-11
lines changed

2 files changed

+64
-11
lines changed

help.go

Lines changed: 60 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func showDockerNetHostAndNotModeNotBothAllowedHelp() {
8686
"It is not allowed to set `--docker.net-host` and `--docker.net-mode` at the same time.",
8787
"",
8888
"How to solve this:",
89-
"1 - Remove one of these two commandline arguments.",
89+
"1 - Remove one of these two commandline arguments.",
9090
"",
9191
)
9292
}
@@ -102,6 +102,42 @@ func showArangodExecutableNotFoundHelp(arangodPath string) {
102102
)
103103
}
104104

105+
// cannnot specify both `--ssl.auto-key` and `--ssl.keyfile`
106+
func showSslAutoKeyAndKeyFileNotBothAllowedHelp() {
107+
showFatalHelp(
108+
"Specifying both `--ssl.auto-key` and `--ssl.keyfile` is not allowed.",
109+
"",
110+
"How to solve this:",
111+
"1 - Remove one of these two commandline arguments.",
112+
"",
113+
)
114+
}
115+
116+
// arangosync is not allowed with given starter mode.
117+
func showArangoSyncNotAllowedWithModeHelp(mode string) {
118+
showFatalHelp(
119+
fmt.Sprintf("ArangoSync is not supported in combination with mode '%s'\n", mode),
120+
"",
121+
"How to solve this:",
122+
"1 - Use the cluster starter mode:",
123+
"",
124+
" `arangodb --starter.mode=cluster --starter.sync ...`",
125+
"",
126+
)
127+
}
128+
129+
// ArangoSync is not found at given path.
130+
func showArangoSyncExecutableNotFoundHelp(arangosyncPath string) {
131+
showFatalHelp(
132+
fmt.Sprintf("Cannot find `arangosync` (expected at `%s`).", arangosyncPath),
133+
"",
134+
"How to solve this:",
135+
"1 - Install ArangoSync locally or run the ArangoDB starter in docker. (see RADME for details).",
136+
" Make sure to use an Enterprise version of ArangoDB.",
137+
"",
138+
)
139+
}
140+
105141
// --sync.server.keyfile is missing
106142
func showSyncMasterServerKeyfileMissingHelp() {
107143
showFatalHelp(
@@ -110,13 +146,13 @@ func showSyncMasterServerKeyfileMissingHelp() {
110146
"How to solve this:",
111147
"1 - If you do not have TLS CA certificate certificate, create it using the following command:",
112148
"",
113-
" `arangosync create tls ca \\",
149+
" `arangodb create tls ca \\",
114150
" --cert=<yourfolder>/tls-ca.crt --key=<yourfolder>/tls-ca.key`",
115151
"",
116-
"2 - Distribute the resulting `tls-ca.crt` file to all machines that you run the starer on.",
152+
"2 - Distribute the resulting `tls-ca.crt` file to all machines (in both datacenters) that you run the starter on.",
117153
"3 - Create a TLS certificate certificate, using the following command:",
118154
"",
119-
" `arangosync create tls keyfile \\",
155+
" `arangodb create tls keyfile \\",
120156
" --cacert=<yourfolder>/tls-ca.crt --cakey=<yourfolder>/tls-ca.key \\",
121157
" --keyfile=<yourfolder>/tls.keyfile \\",
122158
" --host=<current host address/name>`",
@@ -136,16 +172,34 @@ func showSyncMasterClientCAFileMissingHelp() {
136172
"How to solve this:",
137173
"1 - Create a client authentication CA certificate using the following command:",
138174
"",
139-
" `arangosync create client-auth ca --cert=<yourfolder>/client-auth-ca.crt --key=<yourfolder>/client-auth-ca.key`",
175+
" `arangodb create client-auth ca --cert=<yourfolder>/client-auth-ca.crt --key=<yourfolder>/client-auth-ca.key`",
140176
"",
141-
"2 - Distribute the resulting `client-auth-ca.crt` file to all machines that you run the starer on.",
177+
"2 - Distribute the resulting `client-auth-ca.crt` file to all machines (in both datacenters) that you run the starter on.",
142178
"3 - Add a commandline argument:",
143179
"",
144180
" `arangodb ... --sync.server.client-cafile=<yourfolder>/client-auth-ca.crt`",
145181
"",
146182
)
147183
}
148184

185+
// --sync.master.jwt-secret is missing
186+
func showSyncMasterJWTSecretMissingHelp() {
187+
showFatalHelp(
188+
"A JWT secret used for authentication of the arangosync syncworkers at the syncmaster is missing.",
189+
"",
190+
"How to solve this:",
191+
"1 - If needed, create JWT secret file using the following command:",
192+
"",
193+
" `arangodb create jwt-secret --secret=<yourfolder>/syncmaster.jwtsecret`",
194+
"",
195+
"2 - Distribute the resulting `syncmaster.jwtsecret` file to all machines in the current datacenter, that you run the starter on.",
196+
"3 - Add a commandline argument:",
197+
"",
198+
" `arangodb ... --sync.master.jwt-secret=<yourfolder>/syncmaster.jwtsecret`",
199+
"",
200+
)
201+
}
202+
149203
// showFatalHelp logs a title and prints additional usages
150204
// underneeth and the exit with code 1.
151205
// Backticks in the lines are colored yellow.

main.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ func mustPrepareService(generateAutoKeyFile bool) (*service.Service, service.Boo
537537
// Auto create key file (if needed)
538538
if sslAutoKeyFile && generateAutoKeyFile {
539539
if sslKeyFile != "" {
540-
log.Fatalf("Cannot specify both --ssl.auto-key and --ssl.keyfile")
540+
showSslAutoKeyAndKeyFileNotBothAllowedHelp()
541541
}
542542
hosts := []string{"arangod.server"}
543543
if sslAutoServerName != "" {
@@ -562,13 +562,12 @@ func mustPrepareService(generateAutoKeyFile bool) (*service.Service, service.Boo
562562
if enableSync {
563563
// Check mode
564564
if !service.ServiceMode(mode).SupportsArangoSync() {
565-
log.Fatalf("ArangoSync is not supported in combination with mode '%s'\n", mode)
565+
showArangoSyncNotAllowedWithModeHelp(mode)
566566
}
567567
if !runningInDocker {
568568
// Check arangosync executable
569569
if _, err := os.Stat(arangoSyncPath); os.IsNotExist(err) {
570-
log.Errorf("Cannot find arangosync (expected at %s).", arangoSyncPath)
571-
log.Fatal("Please install ArangoSync locally or run the ArangoDB starter in docker (see README for details).")
570+
showArangoSyncExecutableNotFoundHelp(arangoSyncPath)
572571
}
573572
log.Debugf("Using %s as default arangosync executable.", arangoSyncPath)
574573
} else {
@@ -593,7 +592,7 @@ func mustPrepareService(generateAutoKeyFile bool) (*service.Service, service.Boo
593592
// Use cluster JWT secret
594593
syncMasterJWTSecretFile = jwtSecretFile
595594
} else {
596-
log.Fatalf("Error: sync.master.jwt-secret is missing")
595+
showSyncMasterJWTSecretMissingHelp()
597596
}
598597
}
599598
if syncMonitoringToken == "" {

0 commit comments

Comments
 (0)