Skip to content

Commit 6661548

Browse files
author
liuminjian
committed
Feature(deploy): support http deployment.
Signed-off-by: liuminjian <[email protected]>
1 parent 8d9c430 commit 6661548

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+1131
-196
lines changed

cli/cli/cli.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
configure "github.com/opencurve/curveadm/internal/configure/curveadm"
3636
"github.com/opencurve/curveadm/internal/configure/hosts"
3737
"github.com/opencurve/curveadm/internal/configure/topology"
38+
"github.com/opencurve/curveadm/internal/daemon"
3839
"github.com/opencurve/curveadm/internal/errno"
3940
"github.com/opencurve/curveadm/internal/storage"
4041
tools "github.com/opencurve/curveadm/internal/tools/upgrade"
@@ -43,6 +44,7 @@ import (
4344
cliutil "github.com/opencurve/curveadm/internal/utils"
4445
log "github.com/opencurve/curveadm/pkg/log/glg"
4546
"github.com/opencurve/curveadm/pkg/module"
47+
pigeoncore "github.com/opencurve/pigeon"
4648
)
4749

4850
type CurveAdm struct {
@@ -70,6 +72,9 @@ type CurveAdm struct {
7072
clusterTopologyData string // cluster topology
7173
clusterPoolData string // cluster pool
7274
monitor storage.Monitor
75+
76+
// pigeon
77+
pigeon *pigeoncore.Pigeon
7378
}
7479

7580
/*
@@ -195,7 +200,8 @@ func (curveadm *CurveAdm) init() error {
195200
curveadm.clusterTopologyData = cluster.Topology
196201
curveadm.clusterPoolData = cluster.Pool
197202
curveadm.monitor = monitor
198-
203+
admServer := daemon.NewServer()
204+
curveadm.pigeon = pigeoncore.NewPigeon([]*pigeoncore.HTTPServer{admServer})
199205
return nil
200206
}
201207

@@ -534,3 +540,7 @@ func (curveadm *CurveAdm) PostAudit(id int64, ec error) {
534540
log.Field("Error", err))
535541
}
536542
}
543+
544+
func (curveadm *CurveAdm) GetPigeon() *pigeoncore.Pigeon {
545+
return curveadm.pigeon
546+
}

cli/command/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"github.com/opencurve/curveadm/cli/command/client"
3232
"github.com/opencurve/curveadm/cli/command/cluster"
3333
"github.com/opencurve/curveadm/cli/command/config"
34+
"github.com/opencurve/curveadm/cli/command/daemon"
3435
"github.com/opencurve/curveadm/cli/command/hosts"
3536
"github.com/opencurve/curveadm/cli/command/monitor"
3637
"github.com/opencurve/curveadm/cli/command/pfs"
@@ -66,6 +67,7 @@ func addSubCommands(cmd *cobra.Command, curveadm *cli.CurveAdm) {
6667
target.NewTargetCommand(curveadm), // curveadm target ...
6768
pfs.NewPFSCommand(curveadm), // curveadm pfs ...
6869
monitor.NewMonitorCommand(curveadm), // curveadm monitor ...
70+
daemon.NewDaemonCommand(curveadm), // curveadm daemon ...
6971

7072
NewAuditCommand(curveadm), // curveadm audit
7173
NewCleanCommand(curveadm), // curveadm clean

cli/command/daemon/cmd.go

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2023 NetEase Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Project: CurveAdm
19+
* Created Date: 2023-12-13
20+
* Author: liuminjian
21+
*/
22+
23+
package daemon
24+
25+
import (
26+
"github.com/opencurve/curveadm/cli/cli"
27+
cliutil "github.com/opencurve/curveadm/internal/utils"
28+
"github.com/spf13/cobra"
29+
)
30+
31+
func NewDaemonCommand(curveadm *cli.CurveAdm) *cobra.Command {
32+
cmd := &cobra.Command{
33+
Use: "daemon",
34+
Short: "Manage curveadm daemon service",
35+
Args: cliutil.NoArgs,
36+
RunE: cliutil.ShowHelp(curveadm.Err()),
37+
}
38+
39+
cmd.AddCommand(
40+
NewStartCommand(curveadm),
41+
NewStopCommand(curveadm),
42+
)
43+
return cmd
44+
}

cli/command/daemon/start.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* Copyright (c) 2023 NetEase Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Project: CurveAdm
19+
* Created Date: 2023-12-13
20+
* Author: liuminjian
21+
*/
22+
23+
package daemon
24+
25+
import (
26+
"github.com/opencurve/curveadm/cli/cli"
27+
"github.com/spf13/cobra"
28+
)
29+
30+
const (
31+
START_EXAMPLR = `Examples:
32+
$ curveadm daemon start # Start daemon service`
33+
)
34+
35+
type startOptions struct {
36+
filename string
37+
}
38+
39+
func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command {
40+
var options startOptions
41+
pigeon := curveadm.GetPigeon()
42+
43+
cmd := &cobra.Command{
44+
Use: "start [OPTIONS]",
45+
Short: "Start daemon service",
46+
Example: START_EXAMPLR,
47+
RunE: func(cmd *cobra.Command, args []string) error {
48+
return pigeon.Start(options.filename)
49+
},
50+
DisableFlagsInUseLine: true,
51+
}
52+
53+
flags := cmd.Flags()
54+
flags.StringVarP(&options.filename, "conf", "c", pigeon.DefaultConfFile(),
55+
"Specify pigeon configure file")
56+
57+
return cmd
58+
}

cli/command/daemon/stop.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (c) 2023 NetEase Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
/*
18+
* Project: CurveAdm
19+
* Created Date: 2023-12-13
20+
* Author: liuminjian
21+
*/
22+
23+
package daemon
24+
25+
import (
26+
"github.com/opencurve/curveadm/cli/cli"
27+
cliutil "github.com/opencurve/curveadm/internal/utils"
28+
"github.com/spf13/cobra"
29+
)
30+
31+
const (
32+
STOP_EXAMPLR = `Examples:
33+
$ curveadm daemon stop # Stop daemon service`
34+
)
35+
36+
type stopOptions struct {
37+
filename string
38+
}
39+
40+
func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command {
41+
var options stopOptions
42+
pigeon := curveadm.GetPigeon()
43+
44+
cmd := &cobra.Command{
45+
Use: "stop",
46+
Short: "Stop daemon service",
47+
Args: cliutil.NoArgs,
48+
Example: STOP_EXAMPLR,
49+
RunE: func(cmd *cobra.Command, args []string) error {
50+
return pigeon.Stop(options.filename)
51+
},
52+
DisableFlagsInUseLine: true,
53+
}
54+
55+
flags := cmd.Flags()
56+
flags.StringVarP(&options.filename, "conf", "c", pigeon.DefaultConfFile(),
57+
"Specify pigeon configure file")
58+
59+
return cmd
60+
}

cli/command/target/start.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ func NewStartCommand(curveadm *cli.CurveAdm) *cobra.Command {
5151

5252
cmd := &cobra.Command{
5353
Use: "start [OPTIONS]",
54-
Short: "Start target deamon",
54+
Short: "Start target daemon",
5555
Args: cliutil.NoArgs,
5656
RunE: func(cmd *cobra.Command, args []string) error {
5757
return runStart(curveadm, options)

cli/command/target/stop.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func NewStopCommand(curveadm *cli.CurveAdm) *cobra.Command {
4747

4848
cmd := &cobra.Command{
4949
Use: "stop [OPTIONS]",
50-
Short: "Stop target deamon",
50+
Short: "Stop target daemon",
5151
Args: cliutil.NoArgs,
5252
RunE: func(cmd *cobra.Command, args []string) error {
5353
return runStop(curveadm, options)

go.mod

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ require (
1212
github.com/jpillora/longestcommon v0.0.0-20161227235612-adb9d91ee629
1313
github.com/kpango/glg v1.6.14
1414
github.com/mattn/go-sqlite3 v1.14.16
15+
github.com/mcuadros/go-defaults v1.2.0
1516
github.com/melbahja/goph v1.3.0
1617
github.com/mitchellh/hashstructure/v2 v2.0.2
1718
github.com/moby/term v0.0.0-20221205130635-1aeaba878587
19+
github.com/opencurve/pigeon v0.0.0-20231207070543-aa3a2494c114
1820
github.com/pingcap/log v1.1.0
1921
github.com/sergi/go-diff v1.2.0
2022
github.com/spf13/cobra v1.7.0
@@ -25,10 +27,47 @@ require (
2527
golang.org/x/crypto v0.8.0
2628
)
2729

30+
require (
31+
github.com/Wine93/grace v0.0.0-20221021033009-7d0348013a3c // indirect
32+
github.com/bytedance/sonic v1.8.7 // indirect
33+
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
34+
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
35+
github.com/facebookgo/grace v0.0.0-20180706040059-75cf19382434 // indirect
36+
github.com/facebookgo/httpdown v0.0.0-20180706035922-5979d39b15c2 // indirect
37+
github.com/facebookgo/stats v0.0.0-20151006221625-1b76add642e4 // indirect
38+
github.com/gin-contrib/sse v0.1.0 // indirect
39+
github.com/gin-gonic/gin v1.9.0 // indirect
40+
github.com/go-playground/locales v0.14.1 // indirect
41+
github.com/go-playground/universal-translator v0.18.1 // indirect
42+
github.com/go-playground/validator/v10 v10.12.0 // indirect
43+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
44+
github.com/golang/mock v1.6.0 // indirect
45+
github.com/google/pprof v0.0.0-20230406165453-00490a63f317 // indirect
46+
github.com/hashicorp/errwrap v1.1.0 // indirect
47+
github.com/hashicorp/go-multierror v1.1.1 // indirect
48+
github.com/imroc/req/v3 v3.33.2 // indirect
49+
github.com/json-iterator/go v1.1.12 // indirect
50+
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0 // indirect
51+
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
52+
github.com/leodido/go-urn v1.2.3 // indirect
53+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
54+
github.com/modern-go/reflect2 v1.0.2 // indirect
55+
github.com/onsi/ginkgo/v2 v2.9.2 // indirect
56+
github.com/quic-go/qpack v0.4.0 // indirect
57+
github.com/quic-go/qtls-go1-18 v0.2.0 // indirect
58+
github.com/quic-go/qtls-go1-19 v0.3.2 // indirect
59+
github.com/quic-go/qtls-go1-20 v0.2.2 // indirect
60+
github.com/quic-go/quic-go v0.33.0 // indirect
61+
github.com/sevlyar/go-daemon v0.1.6 // indirect
62+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
63+
github.com/ugorji/go/codec v1.2.11 // indirect
64+
golang.org/x/arch v0.3.0 // indirect
65+
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect
66+
)
67+
2868
require (
2969
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 // indirect
3070
github.com/Microsoft/go-winio v0.6.1 // indirect
31-
github.com/Shopify/logrus-bugsnag v0.0.0-20171204204709-577dee27f20d // indirect
3271
github.com/VividCortex/ewma v1.2.0 // indirect
3372
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d // indirect
3473
github.com/benbjohnson/clock v1.3.0 // indirect
@@ -81,18 +120,21 @@ require (
81120
github.com/subosito/gotenv v1.4.2 // indirect
82121
github.com/theupdateframework/notary v0.7.0 // indirect
83122
go.uber.org/atomic v1.10.0 // indirect
84-
go.uber.org/multierr v1.8.0 // indirect
85-
golang.org/x/mod v0.9.0 // indirect
123+
go.uber.org/multierr v1.11.0 // indirect
124+
golang.org/x/mod v0.10.0 // indirect
86125
golang.org/x/net v0.9.0 // indirect
87126
golang.org/x/sys v0.7.0 // indirect
88127
golang.org/x/term v0.7.0 // indirect
89128
golang.org/x/text v0.9.0 // indirect
90-
golang.org/x/tools v0.7.0 // indirect
91-
google.golang.org/protobuf v1.29.1 // indirect
129+
golang.org/x/tools v0.8.0 // indirect
130+
google.golang.org/protobuf v1.30.0 // indirect
92131
gopkg.in/ini.v1 v1.67.0 // indirect
93132
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
94133
gopkg.in/yaml.v3 v3.0.1 // indirect
95-
gotest.tools/v3 v3.0.3 // indirect
96134
)
97135

98136
replace github.com/melbahja/goph v1.3.0 => github.com/Wine93/goph v0.0.0-20220907033045-3b286d827fb3
137+
138+
replace github.com/quic-go/quic-go => github.com/quic-go/quic-go v0.32.0
139+
140+
replace go.uber.org/multierr => go.uber.org/multierr v1.8.0

0 commit comments

Comments
 (0)