-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: liuminjian <[email protected]>
- Loading branch information
liuminjian
committed
Dec 15, 2023
1 parent
a703f1e
commit 1afda6d
Showing
79 changed files
with
1,165 additions
and
190 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
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,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 | ||
} |
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,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 ~/.curveadm/daemon/config/pigeon.yaml # Start an daemon 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 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 | ||
} |
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 (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 ~/.curveadm/daemon/config/pigeon.yaml # Stop an daemon 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 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 | ||
} |
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.