Skip to content

Commit

Permalink
1.add http deployment method
Browse files Browse the repository at this point in the history
Signed-off-by: liuminjian <[email protected]>
  • Loading branch information
liuminjian committed Dec 13, 2023
1 parent 67138fb commit 5afef56
Showing 77 changed files with 1,159 additions and 187 deletions.
11 changes: 11 additions & 0 deletions cli/cli/cli.go
Original file line number Diff line number Diff line change
@@ -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"
@@ -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 {
@@ -71,6 +73,9 @@ type CurveAdm struct {
clusterPoolData string // cluster pool
clusterType string // cluster type like develop, production, etc.
monitor storage.Monitor

// pigeon
pigeon *pigeoncore.Pigeon
}

/*
@@ -197,6 +202,8 @@ func (curveadm *CurveAdm) init() error {
curveadm.clusterPoolData = cluster.Pool
curveadm.monitor = monitor
curveadm.clusterType = cluster.Type
admServer := daemon.NewServer()
curveadm.pigeon = pigeoncore.NewPigeon([]*pigeoncore.HTTPServer{admServer})
return nil
}

@@ -536,3 +543,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
@@ -31,6 +31,7 @@ import (
"github.com/opencurve/curveadm/cli/command/client"
"github.com/opencurve/curveadm/cli/command/cluster"
"github.com/opencurve/curveadm/cli/command/config"
"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"
@@ -66,6 +67,7 @@ func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) {
target.NewTargetCommand(curveadm), // curveadm target ...
pfs.NewPFSCommand(curveadm), // curveadm pfs ...
monitor.NewMonitorCommand(curveadm), // curveadm monitor ...
daemon.NewDaemonCommand(curveadm), // curveadm deamon ...

NewAuditCommand(curveadm), // curveadm audit
NewCleanCommand(curveadm), // curveadm clean
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 deamon 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 -c config/pigeon.yaml # Start an http service to receive requests`
)

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 http 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 -c config/pigeon.yaml # Stop an http 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 http 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
}
54 changes: 48 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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
@@ -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
@@ -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 5afef56

Please sign in to comment.