Skip to content

Commit

Permalink
Feature(deploy): support http deployment.
Browse files Browse the repository at this point in the history
Signed-off-by: liuminjian <liuminjian@chinatelecom.cn>
  • Loading branch information
liuminjian committed Dec 26, 2023
1 parent 7577836 commit 07fda7a
Show file tree
Hide file tree
Showing 80 changed files with 1,131 additions and 196 deletions.
12 changes: 11 additions & 1 deletion cli/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
configure "github.com/opencurve/curveadm/internal/configure/curveadm"
"github.com/opencurve/curveadm/internal/configure/hosts"
"github.com/opencurve/curveadm/internal/configure/topology"
"github.com/opencurve/curveadm/internal/daemon"
"github.com/opencurve/curveadm/internal/errno"
"github.com/opencurve/curveadm/internal/storage"
tools "github.com/opencurve/curveadm/internal/tools/upgrade"
Expand All @@ -43,6 +44,7 @@ import (
cliutil "github.com/opencurve/curveadm/internal/utils"
log "github.com/opencurve/curveadm/pkg/log/glg"
"github.com/opencurve/curveadm/pkg/module"
pigeoncore "github.com/opencurve/pigeon"
)

type CurveAdm struct {
Expand Down Expand Up @@ -70,6 +72,9 @@ type CurveAdm struct {
clusterTopologyData string // cluster topology
clusterPoolData string // cluster pool
monitor storage.Monitor

// pigeon
pigeon *pigeoncore.Pigeon
}

/*
Expand Down Expand Up @@ -195,7 +200,8 @@ func (curveadm *CurveAdm) init() error {
curveadm.clusterTopologyData = cluster.Topology
curveadm.clusterPoolData = cluster.Pool
curveadm.monitor = monitor

admServer := daemon.NewServer()
curveadm.pigeon = pigeoncore.NewPigeon([]*pigeoncore.HTTPServer{admServer})
return nil
}

Expand Down Expand Up @@ -534,3 +540,7 @@ func (curveadm *CurveAdm) PostAudit(id int64, ec error) {
log.Field("Error", err))
}
}

func (curveadm *CurveAdm) GetPigeon() *pigeoncore.Pigeon {
return curveadm.pigeon
}
2 changes: 2 additions & 0 deletions cli/command/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/opencurve/curveadm/cli/command/cluster"
"github.com/opencurve/curveadm/cli/command/config"
copycmd "github.com/opencurve/curveadm/cli/command/copy"
"github.com/opencurve/curveadm/cli/command/daemon"
"github.com/opencurve/curveadm/cli/command/hosts"
"github.com/opencurve/curveadm/cli/command/monitor"
"github.com/opencurve/curveadm/cli/command/pfs"
Expand Down Expand Up @@ -68,6 +69,7 @@ func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) {
pfs.NewPFSCommand(curveadm), // curveadm pfs ...
monitor.NewMonitorCommand(curveadm), // curveadm monitor ...
copycmd.NewCopyCommand(curveadm), // curveadm copy ...
daemon.NewDaemonCommand(curveadm), // curveadm daemon ...

NewAuditCommand(curveadm), // curveadm audit
NewCleanCommand(curveadm), // curveadm clean
Expand Down
44 changes: 44 additions & 0 deletions cli/command/daemon/cmd.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* Copyright (c) 2023 NetEase Inc.
*
* 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.
*/

/*
* Project: CurveAdm
* Created Date: 2023-12-13
* Author: liuminjian
*/

package daemon

import (
"github.com/opencurve/curveadm/cli/cli"
cliutil "github.com/opencurve/curveadm/internal/utils"
"github.com/spf13/cobra"
)

func NewDaemonCommand(curveadm *cli.CurveAdm) *cobra.Command {
cmd := &cobra.Command{
Use: "daemon",
Short: "Manage curveadm daemon service",
Args: cliutil.NoArgs,
RunE: cliutil.ShowHelp(curveadm.Err()),
}

cmd.AddCommand(
NewStartCommand(curveadm),
NewStopCommand(curveadm),
)
return cmd
}
58 changes: 58 additions & 0 deletions cli/command/daemon/start.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright (c) 2023 NetEase Inc.
*
* 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.
*/

/*
* Project: CurveAdm
* Created Date: 2023-12-13
* Author: liuminjian
*/

package daemon

import (
"github.com/opencurve/curveadm/cli/cli"
"github.com/spf13/cobra"
)

const (
START_EXAMPLR = `Examples:
$ curveadm daemon start # Start daemon service`
)

type startOptions struct {
filename string
}

func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command {
var options startOptions
pigeon := curveadm.GetPigeon()

cmd := &cobra.Command{
Use: "start [OPTIONS]",
Short: "Start daemon service",
Example: START_EXAMPLR,
RunE: func(cmd *cobra.Command, args []string) error {
return pigeon.Start(options.filename)
},
DisableFlagsInUseLine: true,
}

flags := cmd.Flags()
flags.StringVarP(&options.filename, "conf", "c", pigeon.DefaultConfFile(),
"Specify pigeon configure file")

return cmd
}
60 changes: 60 additions & 0 deletions cli/command/daemon/stop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2023 NetEase Inc.
*
* 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.
*/

/*
* Project: CurveAdm
* Created Date: 2023-12-13
* Author: liuminjian
*/

package daemon

import (
"github.com/opencurve/curveadm/cli/cli"
cliutil "github.com/opencurve/curveadm/internal/utils"
"github.com/spf13/cobra"
)

const (
STOP_EXAMPLR = `Examples:
$ curveadm daemon stop # Stop daemon service`
)

type stopOptions struct {
filename string
}

func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command {
var options stopOptions
pigeon := curveadm.GetPigeon()

cmd := &cobra.Command{
Use: "stop",
Short: "Stop daemon service",
Args: cliutil.NoArgs,
Example: STOP_EXAMPLR,
RunE: func(cmd *cobra.Command, args []string) error {
return pigeon.Stop(options.filename)
},
DisableFlagsInUseLine: true,
}

flags := cmd.Flags()
flags.StringVarP(&options.filename, "conf", "c", pigeon.DefaultConfFile(),
"Specify pigeon configure file")

return cmd
}
2 changes: 1 addition & 1 deletion cli/command/target/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command {

cmd := &cobra.Command{
Use: "start [OPTIONS]",
Short: "Start target deamon",
Short: "Start target daemon",
Args: cliutil.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return runStart(curveadm, options)
Expand Down
2 changes: 1 addition & 1 deletion cli/command/target/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command {

cmd := &cobra.Command{
Use: "stop [OPTIONS]",
Short: "Stop target deamon",
Short: "Stop target daemon",
Args: cliutil.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
return runStop(curveadm, options)
Expand Down
54 changes: 48 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ require (
github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629
github.com/kpango/glg v1.6.14
github.com/mattn/go-sqlite3 v1.14.16
github.com/mcuadros/go-defaults v1.2.0
github.com/melbahja/goph v1.3.0
github.com/mitchellh/hashstructure/v2 v2.0.2
github.com/moby/term v0.0.0-20221205130635-1aeaba878587
github.com/opencurve/pigeon v0.0.0-20231207070543-aa3a2494c114
github.com/pingcap/log v1.1.0
github.com/sergi/go-diff v1.2.0
github.com/spf13/cobra v1.7.0
Expand All @@ -25,10 +27,47 @@ require (
golang.org/x/crypto v0.8.0
)

require (
github.com/Wine93/grace v0.0.0-20221021033009-7d0348013a3c // indirect
github.com/bytedance/sonic v1.8.7 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/facebookgo/grace v0.0.0-20180706040059-75cf19382434 // indirect
github.com/facebookgo/httpdown v0.0.0-20180706035922-5979d39b15c2 // indirect
github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/gin-gonic/gin v1.9.0 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.12.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/imroc/req/v3 v3.33.2 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
github.com/leodido/go-urn v1.2.3 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/onsi/ginkgo/v2 v2.9.2 // indirect
github.com/quic-go/qpack v0.4.0 // indirect
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect
github.com/quic-go/qtls-go1-19 v0.3.2 // indirect
github.com/quic-go/qtls-go1-20 v0.2.2 // indirect
github.com/quic-go/quic-go v0.33.0 // indirect
github.com/sevlyar/go-daemon v0.1.6 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.11 // indirect
golang.org/x/arch v0.3.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
)

require (
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
github.com/VividCortex/ewma v1.2.0 // indirect
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
github.com/benbjohnson/clock v1.3.0 // indirect
Expand Down Expand Up @@ -81,18 +120,21 @@ require (
github.com/subosito/gotenv v1.4.2 // indirect
github.com/theupdateframework/notary v0.7.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/mod v0.9.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/mod v0.10.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/tools v0.7.0 // indirect
google.golang.org/protobuf v1.29.1 // indirect
golang.org/x/tools v0.8.0 // indirect
google.golang.org/protobuf v1.30.0 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gotest.tools/v3 v3.0.3 // indirect
)

replace github.com/melbahja/goph v1.3.0 => github.com/Wine93/goph v0.0.0-20220907033045-3b286d827fb3

replace github.com/quic-go/quic-go => github.com/quic-go/quic-go v0.32.0

replace go.uber.org/multierr => go.uber.org/multierr v1.8.0
Loading

0 comments on commit 07fda7a

Please sign in to comment.