-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support start cluster cmd (#27)
Signed-off-by: shilinlee <836160610@qq.com>
- Loading branch information
Showing
35 changed files
with
1,556 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package cluster | ||
|
||
import ( | ||
"github.com/openGemini/gemix/pkg/cluster/manager" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func shellCompGetClusterName(cm *manager.Manager, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
var result []string | ||
//clusters, _ := cm.GetClusterList() | ||
//for _, c := range clusters { | ||
// if strings.HasPrefix(c.Name, toComplete) { | ||
// result = append(result, c.Name) | ||
// } | ||
//} | ||
return result, cobra.ShellCompDirectiveNoFileComp | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,7 @@ func init() { | |
installCmd(), | ||
installCmd2(), | ||
startCmd, | ||
startCmd2(), | ||
stopCmd, | ||
uninstallCmd, | ||
statusCmd, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2023 Huawei Cloud Computing Technologies Co., Ltd. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package cluster | ||
|
||
import ( | ||
"github.com/openGemini/gemix/utils" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var startOpts utils.StartOptions | ||
|
||
func startCmd2() *cobra.Command { | ||
var ( | ||
initPasswd bool | ||
) | ||
|
||
var cmd = &cobra.Command{ | ||
Use: "start2 <cluster-name>", | ||
Short: "Start an openGemini cluster", | ||
Long: `Start an openGemini cluster`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
if len(args) != 1 { | ||
return cmd.Help() | ||
} | ||
|
||
clusterName := args[0] | ||
err := cm.StartCluster(clusterName, gOpt) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// TODO: init password | ||
return nil | ||
}, | ||
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { | ||
switch len(args) { | ||
case 0: | ||
return shellCompGetClusterName(cm, toComplete) | ||
default: | ||
return nil, cobra.ShellCompDirectiveNoFileComp | ||
} | ||
}, | ||
} | ||
cmd.Flags().BoolVar(&initPasswd, "init", false, "Initialize a secure root password for the database") | ||
cmd.Flags().StringSliceVarP(&gOpt.Roles, "role", "R", nil, "Only start specified roles") | ||
cmd.Flags().StringSliceVarP(&gOpt.Nodes, "node", "N", nil, "Only start specified nodes") | ||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[Unit] | ||
Description={{.ServiceName}} service | ||
After=syslog.target network.target remote-fs.target nss-lookup.target | ||
|
||
[Service] | ||
{{- if .MemoryLimit}} | ||
MemoryLimit={{.MemoryLimit}} | ||
{{- end}} | ||
{{- if .CPUQuota}} | ||
CPUQuota={{.CPUQuota}} | ||
{{- end}} | ||
{{- if .IOReadBandwidthMax}} | ||
IOReadBandwidthMax={{.IOReadBandwidthMax}} | ||
{{- end}} | ||
{{- if .IOWriteBandwidthMax}} | ||
IOWriteBandwidthMax={{.IOWriteBandwidthMax}} | ||
{{- end}} | ||
{{- if .LimitCORE}} | ||
LimitCORE={{.LimitCORE}} | ||
{{- end}} | ||
LimitNOFILE=1000000 | ||
LimitSTACK=10485760 | ||
|
||
{{- if .GrantCapNetRaw}} | ||
AmbientCapabilities=CAP_NET_RAW | ||
{{- end}} | ||
User={{.User}} | ||
ExecStart=/bin/bash -c '{{.DeployDir}}/scripts/run_{{.ServiceName}}.sh' | ||
|
||
{{- if .Restart}} | ||
Restart={{.Restart}} | ||
{{else}} | ||
Restart=always | ||
{{end}} | ||
RestartSec=15s | ||
{{- if .DisableSendSigkill}} | ||
SendSIGKILL=no | ||
{{- end}} | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.